在我的代码中,我向 https:// 端点发出 WCF 请求。有时,无论出于何种原因,WCF 服务器都无法访问,然后我的代码将产生异常:

System.TimeoutException
The request channel timed out while waiting for a reply after 00:01:00.
Increase the timeout value passed to the call to Request or increase
the SendTimeout value on the Binding. The time allotted to this operation
may have been a portion of a longer timeout.

并且异常的 .StackTrace 包含以下文本:
Server stack trace: <<<< THE QUESTION IS ABOUT THIS VERY LINE
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   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 [my code here invoking an OperatiionContract-attributed method
.InnerException 是另一个带有以下消息的 TimeoutException:
The HTTP request to 'https://management.core.windows.net/subscription-id-here/
   services/hostedservices/service-name-here/deployments/deployment-id-here'
has exceeded 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 措辞。

如果我的请求甚至没有被服务器响应,为什么它是“服务器”?

最佳答案

连接双方都可能发生超时;客户端或服务器。因此,根据您的异常,我会说客户端连接到服务器,但由于未及时生成响应(基于服务器对 sendTimeout 的绑定(bind)),WCF 响应如您所见。

有关超时设置的更多信息,请参阅 http://msdn.microsoft.com/en-us/library/hh924831(v=vs.110).aspx

关于c# - 当客户端甚至无法连接到 WCF 服务器时,为什么我会收到 "server stack trace"的异常?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14041786/

10-11 05:19