【问题标题】:Web Services: How to debug System.Net.WebException?Web 服务:如何调试 System.Net.WebException?
【发布时间】:2014-01-02 13:44:03
【问题描述】:

我有一个作为 Windows 服务运行以连接到 Web 服务的客户端。我在可以从浏览器访问 Web 服务的虚拟机上运行该 Windows 服务;但是,当我尝试从客户端运行服务时,它不起作用。

这里是例外:

System.ServiceModel.EndpointNotFoundException:在http://pmht.plexxis.com/clientsdk.asmx 处没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。 ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 连接尝试失败,因为连接方在一段时间后没有正确响应,或建立连接失败,因为连接的主机未能在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket & socket) 的 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 响应 10.0.1.96:80 , IPAddress& 地址, ConnectSocketState 状态, IAsyncResult asyncResult, Exception& 异常) --- 内部异常堆栈跟踪结束 --- 在 System.Net.HttpWebRequest.GetRequestStream() 的 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) 在 System. ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() --- 内部异常堆栈跟踪结束 --- 服务器堆栈跟踪:位于 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() 处System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,对象 [] 输入,对象 [] 输出, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies。 RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) 在 Client.Core.PMH.Cli entSDKSoap.Login(Int32 ClientId, String Key) at Client.Core.PMH.ClientSDKSoapClient.Login(Int32 ClientId, String Key) at Client.Core.ClientService.OnStart(String[] args)

我尝试使用 Fiddler Web Debugger 来确定发生了什么;然而,无济于事。它表明没有任何东西被发送或接收。我还想指出,如果我回滚虚拟机,它可以工作。

就在此故障开始之前,我重新启动了 VM。当计算机启动时,我看到了一些关于公钥证书的信息;我认为这可能与问题有关。我用谷歌搜索并尝试了推荐的方法,结果是一样的,所以我不能 100% 确定这与问题有关。此外,另一个 VM 可以毫无问题地连接。

编辑: 基于 cmets,我尝试从 VM ping 站点。请求超时;但是,然后我做了一个 ipconfig /flushdns 并开始解决。不幸的是,同样的异常又被抛出了。

如何开始调试此类问题?

【问题讨论】:

  • 从 VM 中,您能否 ping Web 服务器(如果它正在接受连接)。可能虚拟机没有正确解析域。
  • 我尝试了您的建议并更新了问题。问题依然存在。
  • 这很奇怪,好吧。所以我试了两次,都失败了。然后我写了我的评论并ping了-t。大约 250 次 ping 后,我决定再次运行 Web 服务,它成功了! @aaroncatlin 请将您的评论作为答案。
  • 我在下面添加了我的答案。很高兴我能帮上忙。

标签: c# .net web-services sockets


【解决方案1】:

如 cmets 中所述,通过尝试 ping 域,确保 VM 能够正确解析 Web 服务名称。

如果不能,请尝试刷新 DNS。

【讨论】:

    【解决方案2】:

    您可能有两个项目,一个是 Web,另一个是服务。

    要开始调试这个问题,可能有两种方法:

    1) (a) 您必须首先构建并运行服务项目。 (b) 然后运行 ​​Web 项目,它就可以工作了。

    2)

    转到您的 Web 项目的 web.config,您将找到您的端点地址,如上面提到的“http://pmht.plexxis.com/clientsdk.asmx”。

    要测试它,将其更改为 localhost:2732 并首先在您的系统上测试。(可能是 2732,您必须先运行服务层,然后再运行 Web)

    另外,我需要知道客户端正在使用哪个 Web 托管服务,即 前任。亚马逊、Azure 等???

    询问此问题的原因是,如果您启动和停止实例,IP 在 Amazon 中会发生变化。 Azure 有不同的配置。

    如果我在正确的轨道上,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-27
      • 2017-07-06
      • 2021-08-02
      相关资源
      最近更新 更多