No connection could be made because the target machine actively refused it 127.0.0.1:57240 at System.Net.Sockets.Socket

匿名 (未验证) 提交于 2019-12-03 02:20:02

问题:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!