WCF 超时未兑现

Mic*_*ens 6 wcf timeout

我是一个广泛使用 WCF 的项目的新手,我对 WCF 的经验并不丰富。我正在尝试追踪一个问题,即我的 UI 在等待长时间运行的服务调用返回时在 10 分钟后出现超时错误。粗略地说,这是我的项目需要的内容:

[service A] <=> [service B] <=> [UI console]
Run Code Online (Sandbox Code Playgroud)

这是我迄今为止收集到的:

  • 超时发生在 serviceA 和 serviceB 之间,而不是在 serviceB 和 UI 控制台之间,因为我实际上有两个单独的 UI 控制台:一个是 MMC 管理单元,一个是 PowerShell 管理单元,并且都表现出相同的 10 分钟超时.

  • 我在 serviceA 和 serviceB 中的端点都使用 basicHttpBinding;两者都有 bindingConfigurations 指定 sendTimeout 和 receiveTimeout 为 30 分钟,而不是 10 分钟。

  • ReliableSession.InactivityTimeout 默认为 10 分钟我读过,但我不相信这些是 ReliableSession 所以它不适用。

  • 我为 WCF 跟踪检测了 serviceB;ServiceTraceViewer 显示了在长时间运行的服务调用开始之前的适当活动,然后在 10 分钟超时(包括 10 分钟超时)之前没有显示。

随意挑战我的任何断言和/或让我知道我还能做些什么来诊断这个问题。

2013.04.04 更新

这是实际的错误消息:

请求通道在 00:09:59.9839984 之后等待回复时超时。增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。分配给此操作的时间可能是较长超时的一部分。

服务器堆栈跟踪:在 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String)动作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage信息)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NextIT.ActiveAdministration 处的 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 处。 DataContracts.IActiveAdministration.PublishAgentSettings() 在 ...

和内部异常:

对“ http://localhost/MyAdminService/”的 HTTP 请求已超过分配的超时时间 00:10:00。分配给此操作的时间可能是较长超时的一部分。

在 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 在 System.ServiceModel.Channels.RequestChannel.Request (消息消息,TimeSpan 超时)

Mic*_*ens 1

有一句古老的格言“如果不起作用,请尝试将其插入”。我如此专注于通过 app.config 文件的痛苦曲折,充满了大火和混乱 - 部分原因是在这个大型项目中实际上有 5 个具有各种绑定和服务的 app.config 文件(!)——我没有注意到代码覆盖配置文件的明显部分:

\n\n
binding.ReceiveTimeout = new TimeSpan(0, 0, 10, 0);\nbinding.SendTimeout = new TimeSpan(0, 0, 10, 0);\n
Run Code Online (Sandbox Code Playgroud)\n\n

叹。

\n\n

但是等等——还有更多。我最初很困惑为什么配置文件中的 30 分钟值没有效果,因为超时发生在 10 分钟?好吧,原来如上代码\xe2\x80\x94中设置的10分钟超时\xe2\x80\x94是从UI控制台到serviceB的。配置文件\xe2\x80\x94中设置的30分钟超时\xe2\x80\x94是从serviceB到serviceA,所以我必须将两者打开得更宽,以便让长时间运行的操作继续进行。

\n