WCF超时未被执行

6

我是一个新手,加入了一个广泛使用WCF的项目,我的WCF经验并不丰富。我正在尝试追踪一个问题,即当等待长时间运行的服务调用返回时,我的UI在10分钟后会出现超时错误。大致来说,我的项目包括以下内容:

[service A] <=> [service B] <=> [UI console]

目前我了解到的情况如下:

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

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

  • ReliableSession.InactivityTimeout默认为10分钟,但我认为这两个都不是ReliableSession,因此不适用。

  • 我为WCF跟踪工具添加了serviceB; ServiceTraceViewer显示了适当的活动,直到长时间运行的服务调用开始,然后在包括10分钟超时在内的之后没有任何内容。

欢迎对我的任何断言提出质疑和/或让我知道我可以做什么来诊断此问题。

2013.04.04更新

以下是实际的错误消息:

The request channel timed out while waiting for a reply after 00:09:59.9839984. 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.

Server stack trace: at 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 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 NextIT.ActiveAdministration.DataContracts.IActiveAdministration.PublishAgentSettings() at ...

内部异常:

HTTP请求'http://localhost/MyAdminService/'已超过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(Message message, TimeSpan timeout)处。

你是否也尝试过调整开启和关闭超时时间? - evgenyl
开放时间(openTimeout)和关闭时间(closeTimeout)均设置为1分钟,因此它们不会是罪魁祸首;我所阅读的关于这些参数的内容似乎也支持这一事实。 - Michael Sorens
我很高兴你解决了问题,但这个问题并不普遍适用。没有其他人能够阅读到出现问题的代码,并且问题的描述也不足以帮助其他人解决超时工作的困扰。 - TamaMcGlinn
2个回答

1

有句老话说"如果不起作用,试着插上它。"我太专注于穿过充满混乱和困惑的app.config文件的曲折转弯--部分原因是这个大项目中实际上有5个带有各种绑定和服务的app.config文件(!)--而没有注意到代码正在覆盖配置文件的明显部分:

binding.ReceiveTimeout = new TimeSpan(0, 0, 10, 0);
binding.SendTimeout = new TimeSpan(0, 0, 10, 0);

叹息。

但是等等,还有更多。一开始我很疑惑为什么配置文件中的30分钟超时值没有生效,因为超时时间只有10分钟?原来,上述代码中设置的10分钟超时时间是从UI控制台到服务B的。而配置文件中设置的30分钟超时时间是从服务B到服务A的,所以我必须同时扩大两者的范围,才能让长时间运行的操作继续进行。


0

感谢您的建议。我确实找到了OperationTimeout,并确认它设置为30分钟,正如您的来源所述(因为它是从SendTimeout设置的),因此这似乎不是问题所在。 - Michael Sorens

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接