问题
I am using this article to fetch yahoo contacts.It is OK and gives me a guid.Then I create a request to http://social.yahooapis.com/v1/user/
with the given guid.But when I want to read the response from the http request I receive an error that says:
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:8555
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
What is the problem?
回答1:
"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port.
once you start the process hosting your service try netstat -anb (requires admin privileges) to verify that it is running and listening on the expected port.
来源:https://stackoverflow.com/questions/19732800/unable-to-connect-to-the-remote-server-in-a-http-request