可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have been developing a web service and a windows service, the web service I have deployed is in another server, and the windows service I have deployed works in my own server, so I use the windows service to call the web service. Everything was fine, but in a few days I have received the below message:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:57240 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4,Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace - -- at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
回答1:
because the target machine actively refused it 127.0.0.1:57240
The "target machine" in this case is the machine on which the failing code is running. Not the remote machine. 127.0.0.1 is the IP address of "localhost", you use it to get two processes that run on the same machine to talk to each other through sockets. Not unusual, it can be an easier alternative to using named pipes for example.
But of course you expect it to connect to another machine, one that actually has an application listening. Something is wrong with your program's config, it is trying to connect to a service that doesn't exist. There's no insight in how that could have happened, your question is missing all details about exactly how you selected the target machine. If you selected it by name rather than IP address then there's something very screwy going on with the naming service on your LAN. Or you simply forgot to change the config when you went from testing mode to deployment mode. Or you gave up trying a bunch of stuff that didn't work because the firewall is blocking access.
回答2:
I think, you need to check your proxy settings in "internet options". If you are using proxy/'hide ip' applications, this problem may be occurs.
In my case i changed proxy settings.
回答3:
Port 57240 looks like a client's application port, your server application is probably running on lower port. So it looks like client crashed and the communication socket was closed.