Search code examples
c#.nethttp-posthttpwebrequest

System.Net.WebException: Unable to connect to the remote server error while just making post with HttpWebRequest?


I have HttpWebRequest and its giving this error.I cannot try this answer because i cannot use local ip.There is a strange issue that in my computer there is no error like this but in the server its giving this error.The database is not in server we are using an api for crud operations.By the way the project is windows service. Its giving this error and then the service is stopping.there is another detail.The server where i install the windows service (its is not a server that has th database.) has %100 cpu usage and almost %100 ram usage.I set the timetout of request 100 seconds but it is not solve the problem.The detailed answer as below

System.Net.WebException: Unable to connect to the remote server ---> 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....

How can i solve this ? And idea? By the way about 50 seconds program trying to post request and then giving the error.Also there is another detail the database owner api has get methods that lists some data i can open them from browser with same link that i used in post


Solution

  • The Problem is about proxy settings of httpwebrequest. Setting a proxy solved this.