We have a background operation (Window service) that we want to use through a proxy server.
Basically, we do this:
public WebClient GetWebClient(){ var webClient = new WebClient(); webClient.proxy = new WebProxy(Configuration.ProxyHost, Configuration.ProxyPort);
A proxy server is one that we ourselves configured using FreeProxy .
I turned on logging on the machine I'm testing with, and I can confirm that requests are executed in proxies when used in Firefox.
Authentication is not required for the proxy server, except that the IP address must be in our office (which, according to Firefox, I do not consider a problem).
However, in our background process, I don't seem to use a proxy server when using the web client:
using(var wc = GetWebClient()) using(var s = wc.OpenRead("someurl")) using(var sr = new StreamReader(s)){ return sr.ReadToEnd(); }
I do not get any errors from the proxy server, but it looks like we just can do without it, even though the proxy is explicitly installed.
It seems that the information returned perfectly, just not through our proxy.
Is there something I am missing when using proxies with WebClient
?
edit: more details. If we disable the proxy service on the server, we will get an exception with which we cannot connect. Thus, it seems like the web client is trying to contact the proxy server, but this traffic does not actually flow through the proxy.
Inner Exception: 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