使用代理服务器连接到webservice时出错(System.Net.WebException:无法连接到远程服务器) [英] error in connection to webservice by using proxy server (System.Net.WebException: Unable to connect to the remote server)
问题描述
亲爱的..
i连接到网络服务以获取特定结果,我的Windows应用程序根据网络服务的响应下载许多文件/>
只有在我的网络浏览器中使用代理程序模拟代理才会出现问题
这是我做的步骤:
dear all..
i am connecting to a web service to get a specific results and my windows applications download many files according to response from web-service
the problem appears only when using a proxy in my internet explorer using program "analog proxy"
this is the steps i made:
tools->internet options->connections->Lan settings-> and i checked use proxy server for Lan..... with address: 192.168.1.240 and port:6588
我的代码连接到网络的服务是:
my code to connect to web-service is:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.o-survey.com");
IWebProxy proxy = request.Proxy;
if (proxy != null)
{
MessageBox.Show("Proxy: {0}"+ proxy.GetProxy(request.RequestUri));
}
else
{
MessageBox.Show("Proxy: {0}Proxy is null; no proxy will be used");
}
WebProxy myProxy = new WebProxy();
Uri newUri = new Uri("http://162.168.1.240:6588");
// Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
myProxy.Address = newUri;
// Create a NetworkCredential object and associate it with the
// Proxy property of request object.
myProxy.Credentials = new NetworkCredential("john", "johngra");
request.Proxy = myProxy;
和在app.config中我放下以下行
and in app.config i put the following line
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" >
</defaultProxy>
</system.net>
i得到此错误:
i got this error:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 192.168.1.240:6588
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at SystemTray.SQSClient.StockQuoteService.getQuote(String symbol, String terminal) in D:\Graphicano\c# projects\SystemTray\SystemTray\Web References\SQSClient\Reference.cs:line 84
at SystemTray.Form1.checker(Int32 updater_action, Int32 show_button) in D:\Graphicano\c# projects\SystemTray\SystemTray\MainForm.cs:line 1108
请尽快解决此问题的任何想法,我需要快速解决它
提前感谢
any idea for solving this problem please as soon as possible, i need to solve it quickly
thanks in advance
推荐答案
你可能需要阅读什么代理服务器是:
代理服务器 [ ^ ]
在您尝试连接并创建代理的计算机上,它必须运行代理服务器。这是一个重新路由请求的软件。在您的情况下,192.168.1.240计算机需要在其上安装代理服务器并进行配置以路由流量。然后您的另一台计算机可以将其用作代理服务器。否则它会给你一个无法连接的消息。
You may need to read up on what proxy servers are:
Proxy Server[^]
On the computer that you are trying to connect to and make the proxy, it MUST be running a proxy server. This is a piece of software that re-routes requests. In your case, the 192.168.1.240 computer needs to have a proxy server INSTALLED on it, and configured, to route traffic. Then your other computer can use it as a proxy server. Otherwise it will give a the "unable to connect" message that you are getting.
WebRequest
对象有一个有用的属性DefaultWebProxy
这会返回你正在尝试的IProxy
对象根据您的系统代理设置进行配置。
http://msdn.microsoft.com/en-us/library/system.net.webrequest.defaultwebproxy.aspx [ ^ ]
TheWebRequest
object has a useful propertyDefaultWebProxy
This returns theIProxy
object you're trying to configure based on your systems proxy settings.
http://msdn.microsoft.com/en-us/library/system.net.webrequest.defaultwebproxy.aspx[^]
这篇关于使用代理服务器连接到webservice时出错(System.Net.WebException:无法连接到远程服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!