by Jim
May 14, 2008 12:38 PM
I'm hosting a WCF service in IIS, on the same development machine as the client application. I was getting a delay of several seconds in my service calls, and a little message in my output window:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
The framework was just swallowing this exception, and my data come through just fine - except for the delay, that is.
I had to run on the option to break when an exception is thrown (Debug->Exceptions in Visual Studio) in order to get some more details:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
The error code is 10060. But I didn't see anything that helped me understand what was going on, even after digging around in the framework. If it wasn't for the delay, I could "fix" it by just ignoring it, which seems to be Microsoft's solution to these swallowed exceptions.
It turned out that the solution was just to turn off the windows firewall, though I never did figure out exactly what was running into the firewall, or why this didn't prevent the call from succeeding.
Also, if I check the "Enable Just My Code" option in Tools->Options->Debugging, then I get no message whatsoever! An exception is thrown and swallowed by the framework, causing several seconds of delay, but with Visual Studio's default configuration, there is no indication during debugging that anything happened.