2

I've faced an strange problem in a very simple WCF service which was working correctly. The service is a web service with only one operation and response, with a BasicHttpBinding and all timeouts (receive, send, connect, open ...) set to 10 seconds. Suddenly one day started to be very slow (mostly by a network problem), but the timeouts seems to be not working.

<binding
openTimeout="00:00:10"
closeTimeout="00:00:10"
sendTimeout="00:00:10"
receiveTimeout="00:00:10" />

I have tried to get these timeouts to work, by connecting to the web service using a socket, and sending nothing and wait a number of seconds, but the connection only is broken after 120 seconds, so definitively the timeouts are not working.

//connect to the web service
sock.Connect(address, port);
//send something invalid
byte[] buffer = Encoding.Default.GetBytes("hello");
sock.Send(buffer);
//wait to be dropped or something
sock.Receive(buffer);

Is there any way to manually drop a connection from the service after a certain amount of time if no bytes are received?

Thanks!

mopicus
  • 159
  • 4

1 Answers1

0

Since you're doing HTTP Binding, are you sure you aren't getting caught by the connection timeout setting in IIS? The default is 2 minutes.

http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults/limits

Specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive. Connections can be considered inactive for the following reasons:

For self-hosted this is still an issue. See this thread for the appropriate binding settings.

HTTP Keep-alive and ServiceHost / C#?

Community
  • 1
  • 1
mpeterson
  • 1,672
  • 12
  • 15