HttpWebRequest WebProxy problem - The connection was closed unexpectedly

时光怂恿深爱的人放手 提交于 2019-12-24 02:24:14

问题


I'm trying to make a HTTP request through an open SOCKS5 proxy. I have verified that the proxy works by setting it as a proxy for Firefox before setting it as the proxy in my C#.Net application by setting request.Proxy = new WebProxy(ip, port);

However, on attempting to run the application and make my request I get an exception - System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.

I'm unsure what is causing this - the proxy seems to be open and working fine. I've also tried this with other seemingly working proxies and get the same exception. Any clues as to why this is happening and how I can go about rectifying it would be much appreciated!


回答1:


It turns out the WebProxy class does not support Socks proxies which is exactly what I was trying to use. How useful!

The question now becomes - How to use a Socks Proxy for HttpWebRequest ?!




回答2:


You can not. check this https://stackoverflow.com/questions/20366665/squid-proxy-reset-connection-immediately



来源:https://stackoverflow.com/questions/3855137/httpwebrequest-webproxy-problem-the-connection-was-closed-unexpectedly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!