简体   繁体   English

WCF超时异常服务器端

[英]WCF Timeout Exception Server Side

I have a WCF service with methods that mostly consist of insert operations. 我有一个WCF服务,其中的方法主要由插入操作组成。 Sometimes due to the insert operations take too much time, clients get timeout exception. 有时由于插入操作花费太多时间,客户端会收到超时异常。 Is there anyway to catch this timeout exceptions inside WCF service (not client)? 无论如何,在WCF服务(不是客户端)中是否可以捕获此超时异常? Can I log this timeout errors? 我可以记录此超时错误吗?

Rather than relying on the communication timeout to control the length of service operations, you could control the allowable time to insert in the application. 您可以控制允许插入应用程序中的时间,而不必依靠通信超时来控制服务操作的时间。 To that end, you could change your service method to be asynchronous and specify a maximum time-to-run that is less than the transport timeout. 为此,您可以将服务方法更改为异步方法,并指定最大运行时间,该时间小于传输超时。

The example in the MSDN “ Cancel Async Tasks after a Period of Time ” may be helpful. MSDN中的示例“ 一段时间后取消异步任务 ”可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM