Odd exception during debug of WCF service
This is a WCF service that is going to be hosted in IIS. When I run debug from vs2010 my WCF client gets this exception:
No connection could be made because the target machine actively refused it
The service URL is the the one dynamically assigned by visual studio, and the WCF service is being run in VS. The odd thing, this exception is actually never passed to my application, I only ran in to it when I started noticing lines like this in the output window:
The thread '' (0xa5c) has exited with code 0 (0x0).
Each time that was thrown in the output window, a System.Net.SocketException
would occur. Why would a VS hosted WCF service be unreachable?
This is a .NET 4.0 WCF service and client
UPDATE I thought i should describe this a little more. The client is making a single call ever开发者_JAVA技巧y 1 second on a timer. I use a flag to determine if the call is complete so i dont overlapp. Just to emphasize, this error is never actually passed to my client. My client behaves as if the call is successful. The only reason I even know that the SocketException is occuring is because I used the VS options to break at Exception.
Where is the SocketException thrown, in the client app or the service? It sounds like the thread is a worker thread being spun up to service the request, so that would be normal...and if the socket exception occurs in the client after the worker thread terminates without a reply, I would put the debugger on the service code to see if it's able to complete the request successfully.
There are a number of common culprits.
1) The port has not been opened in the firewall.
2) The WCF endpoint code is throwing an exception at startup, often this can be a permissions issue or a missing dll.
3) The Address, Binding or Configuration is not identical on the endpoint and the client.
The error you received is a TCP error, not a WCF error. Here are some things to check:
If you are running service and client on the same machine (dev/staging), try using 127.0.0.1 rather than localhost when addressing the service
Double-check the port that the service is running on and make sure there are no conflicts.
Also make sure that you are addressing the correct port in your calls from the client.
The thread '' (0xa5c) has exited with code 0 (0x0).
This is normal and only pertains to a worker thread finishing its work.
No connection could be made because the target machine actively refused it
Either the binding referes to another machine to the port is wrong.
精彩评论