2

我有一个包含三个 WCF 服务的程序,当我在本地运行它们时(即:服务器和客户端都在本地主机上),一切正常。但是,当我通过网络测试它们时,我在两个服务上得到了 TimoutException,但另一个没有。我已经禁用了参与测试的所有机器上的防火墙。我既可以 ping 服务器,也可以从客户端访问 wsdl“您已创建服务”网页

工作的服务使用带流的 BasicHttpBinding,而两个不工作的服务使用 WSDualHttpBinding。使用 WSDualHttpBinding 的服务都有 CallbackContracts。对于这个问题的含糊之处,我深表歉意,但我不确定要包含哪些代码,甚至不确定从哪里开始寻找解决方案。

非工作绑定:

public static Binding CreateHTTPBinding()
{
  var binding = new WSDualHttpBinding();

  binding.MessageEncoding = WSMessageEncoding.Mtom;

  binding.MaxBufferPoolSize = 2147483647;
  binding.MaxReceivedMessageSize = 2147483647;
  binding.Security.Mode = WSDualHttpSecurityMode.None;
  return binding;
}

异常堆栈跟踪:

Unhandled Exception: System.TimeoutException: The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.

Server stack trace:
   at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
   at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IDemeService.Register()
   at DemeServiceClient.Register()
   at DemeClient.Client.Start()
   at DemeClient.Program.Main(String[] args)
4

2 回答 2

0

您正在使用DualHttpBinding. 这意味着您正在设置一个双工通道,服务器可以在其中向客户端发送消息(不是响应消息,而是传入消息)。但是您还没有设置clientBaseAddress客户端将在哪里监听来自服务器的传入消息。这就是导致此问题的原因。来自http://msdn.microsoft.com/en-us/library/system.servicemodel.wsdualhttpbinding.aspx

此绑定要求客户端具有为服务提供回调端点的公共 URI。这是由 ClientBaseAddress 提供的。双重绑定将客户端的 IP 地址暴露给服务。客户端应该使用安全性来确保它只连接到它信任的服务。

于 2013-03-07T18:50:01.447 回答
0

You may enable System.Net tracing on both sides and read about the Timeout exception.

http://support.microsoft.com/kb/947285

于 2010-03-27T03:46:16.727 回答