1

As SOCKS proxy server can handle http requests as well along with socket requests. So I am trying to pass make http request through SOCKS proxy server, but I am not able to do that. I have successfully made socket request through SOCKS proxy server and http request through http proxy server. This is the way I made a http request through http proxy server. string sURL; sURL = textBoxWebAddress.Text;

            WebRequest wrGETURL;
            wrGETURL = WebRequest.Create(sURL);

            WebProxy myProxy = new WebProxy(textBoxSOCKSHost.Text, int.Parse(textBoxSOCKSPort.Text));
            myProxy.BypassProxyOnLocal = true;

            wrGETURL.Proxy = myProxy;//WebProxy.GetDefaultProxy();

            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();

            StreamReader objReader = new StreamReader(objStream);

            string sLine = "";
            int i = 0;

            while (sLine != null)
            {
                i++;
                sLine = objReader.ReadLine();
                if (sLine != null)
                    Console.Write(sLine);
            }

But when I enter address and port of SOCKS proxy server, it gives connection failure error. What I am doing wrong? Thanks.

4
  • Is the proxy server up and running? can you use the same proxy in for example IE?
    – Erwin
    Aug 28, 2012 at 14:13
  • 1
    WebClient/WebRequest classes don't support SOCKS proxy.
    – L.B
    Aug 28, 2012 at 14:26
  • Yes Erwin proxy server is running, it is accepting socket calls. Aug 29, 2012 at 4:51
  • So how to make a WCF http call to pass through SOCKS proxy server? Aug 29, 2012 at 4:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.