I have a windows service (.NET), that is trying to connect to a remote client. But it is throwing an exception. While I tested the same code, as an windows application, there was no such issue.
The error:
Unable to connect to the remote serverSystem.Net.Sockets.SocketException (0x80004005): 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
My code:
var wb = new WebClient()
var response = wb.UploadValues(ConfigurationManager.AppSettings["Query"], "POST", data);
Most importantly, the same code works in development environment while running it as a part of Windows forms application.
It got solved it changing the profile in control panel-> admin tools -> service -> select service name ->stop-> right click properties -> log on -> change from Local system to this account -> provided my credentials -> click on apply -> OK.
Restart the service. BTW I had admin privileges.