“无法连接到远程服务器" [英] "Unable to connect to the remote server"

查看:124
本文介绍了“无法连接到远程服务器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以很好地从 Windows 表单程序调用 3rd 方供应商的 Web 服务.当我尝试从 WCF Web 服务调用相同的 Web 服务和 Web 方法以及相同的 URL 时,我收到以下错误:

I'm able to call a 3rd party vendor's web service from a Windows form program just fine. When I try to call the same web service and web method and same URL from a WCF web service I get the following error:

ExportValuationPolicyNumber:Exception=System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.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 66.77.241.76:80

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   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()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at TFBIC.RCT.WCFWebServices.ExpressLync.ValuationServiceWse.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\Web References\ExpressLync\Reference.cs:line 519
   at TFBIC.RCT.WCFWebServices.ValuationService.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\ValuationService.svc.cs:line 97

我基本上是在尝试为供应商 .asmx/WSE3 服务编写 WCF 包装器.让我们不要离题 - 但微软表示 WCF 可以调用 WSE3,但只能在 SSL 开启的情况下,而我的供应商 - 信不信由你 - 不允许 SSL 连接.所以我一直在编写包装器,以便我可以从 BizTalk 2009 调用.现在,我正在通过控制台程序测试包装器.

I'm basically trying to write a WCF wrapper for the vendor .asmx/WSE3 service. Let's not get off point - but Microsoft says WCF can call WSE3, but only with SSL turned on, and my vendor - believe it or not - is not allowing SSL connection. So I'mn stuck writing the wrapper so I can call from BizTalk 2009. Right now, I'm testing the wrapper via a Console program.

我什至可以做些什么来调试?我在调用 .asmx 服务的 WCF 服务之前和之后添加了 EventLog 跟踪 - 所以我知道这就是它发生的地方(加上上面错误中的行号).

What can I even do to debug? I've added EventLog traces before and after the WCF service where it calls the .asmx service - so I know that's where it's blowing (plus the line number in the error above).

我的 web.config 中有以下内容:

I have the following in my web.config:

<microsoft.web.services3>
        <diagnostics>
                <trace enabled="true" 
                           input="c:\inetpub\wwwroot\wsetraces\InputTrace.webinfo" 
                           output="c:\inetpub\wwwroot\wsetraces\OutputTrace.webinfo" />
                <detailedErrors enabled="true" />
        </diagnostics>
</microsoft.web.services3>

并且我已授予每个人对该目录的完全访问权限 - 但那里没有任何痕迹.

and I have given the directory full-access to everyone - yet no trace appears there.

接下来我可以寻找或尝试哪些东西来调试它?

What are some things I can look for or try next to debug this?

理论上ping"结果应该无关紧要,因为该网站正在通过调用它的 Windows 窗体程序运行.

In theory "ping" results should not matter, because the website is working from the Windows form program that calls it just fine.

尽管如此 - 这是 Ping 显示的内容,对我来说看起来有点可疑:

Nevertheless - here is what Ping shows and it looks a little questionable to me:

C:\Users\uxnxw01>ping rct.msbexpress.net

C:\Users\uxnxw01>ping rct.msbexpress.net

Pinging rct.msbexpress.net [66.77.241.56] with 32 bytes of data:
Reply from 10.193.99.5: Destination net unreachable.
Reply from 10.193.99.5: Destination net unreachable.
Request timed out.
Reply from 10.193.99.5: Destination net unreachable.

Ping statistics for 66.77.241.56:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

谢谢,

尼尔·沃尔特斯

<小时>WireShark分析


WireShark analysis

我确实运行了 Wireshark - 在下面的评论中发布了一些结果.然而,在阅读更多之后,它并不总是说目的地无法到达".但是在它失败的情况下,我永远不会得到任何数据回.我仍然很困惑接下来要做什么.我一直在比较数据包,但它很慢而且很混乱.例如,我仍然没有找到我在请求数据包中传递的密钥(特定的 policyNum).我还在一个有效的语句中看到了一些无法到达目的地"的语句.

I did run Wireshark - posted some results in comment below. However, after reading it more, it does not always say "Destination Unreachable". But in the case where it's failing, I never get any databack. I'm still confused what to do next. I have been comparing packets but it's slow and confusing. For instance, I still haven't found the key (a specific policyNum) that I am passing in the request packet. I also see a few "Destination Unreachable" statements in the one that worked.

在一个有效的,我从来没有看到66.77.241.76,我只看到我们公司的代理.但是我在配置(或代码)中看不到任何会告诉 WSE3 使用或不使用代理的内容.

In the one that works, I never see 66.77.241.76, I only see our company's proxy. But I can't see anything in the config (or code) that would tell WSE3 to use or not use the proxy.

<小时>Telnet 结果:


Telnet results:

C:\Users\uxnxw01>telnet 66.77.241.56 80
Connecting To 66.77.241.56...Could not open connection to the host, on port 80:
Connect failed

C:\Users\uxnxw01>telnet 66.77.241.76 80
Connecting To 66.77.241.76...Could not open connection to the host, on port 80:
Connect failed

我不确定这证明了什么.就像我说的,我绝对可以通过直接调用它的 WSE3 接口从 Windows 窗体调用相同的 web 服务.我知道我可以通过这种方式到达那里.

I'm not sure what this proves. Like I said, I CAN definitely call the same webservice from a Windows form by directly calling its WSE3 interface. I know that I can get there that way.

我认为这两个程序的主要区别在于一个在 Win Form 下运行并直接调用 WSE3.那个有效.失败的代码基本上是 99% 相同的代码,作为 WCF 服务发布,因此它在 IIS 下运行(然后控制台程序调用我机器上的 WCF/IIS 服务,后者又调用 WSE3 服务).

I'm thinking the main differences in the two programs is that one is running under a Win Form and calling WSE3 directly. That one works. The one that fails is basically 99% same code, published as a WCF service, so it's running under IIS (then a console program calls the WCF/IIS service on my machine, which in turns calls the WSE3 service).

IIS 不使用同一个代理有什么原因吗?

推荐答案

感谢上述所有帮助 - 但这里是真正的答案:

Thanks to all the help above - but here's the real answer:

valservice.Proxy = new System.Net.WebProxy("http://10.192.xx.xx:8080", 真);

valservice.Proxy = new System.Net.WebProxy("http://10.192.xx.xx:8080", true);

在 IIS 下运行的 WCF 服务显然没有使用相同的代理,所以我在代码中手动设置了它.我会发布另一个问题,看看是否有办法在配置文件中做到这一点.

The WCF service running under IIS was apparently NOT using the same proxy, so I set it manually in the code. I'll post another question to see if there is a way to do this in config file.

这篇关于“无法连接到远程服务器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆