none
请教一个wcf问题,如何设置OperationTimeout的属性 RRS feed

  • 问题

  • 碰到如下问题

    xxxx的请求操作在配置的超时(00:00:59.9531250)内未收到回复。分配给该操作的时间可能是更长超时的一部分。这可能由于服务仍在处理操作或服务无法发送回复消息。请考虑增加操作超时(将通道/代理转换为 IContextChannel 并设置 OperationTimeout 属性)并确保服务能够连接到客户端。

    但我没有找到OperationTimeout属性在哪里可以设置。请教各位高手。
    2009年12月9日 9:24

答案

  • 这里有个文章对此进行了分析。
    默认的超时设置是1分钟,任何读写数据库超过一分钟都会导致这个错误

    Problem

    The same code sample will throw an Operation Timeout Error under the following circumstances:

    • If there is a delay for More than a Minute in database responses
    • OLEDB/SQL/ODBC Command Execution
    • Dataadapter.Fill with DataTable or DataSet
    • Reading data using DataReader

    The delay can happen in so many ways such as execution from Database, execution of Business logic from different layers, delay response from other interfaces referenced in the application. Because of these delays, the WCF client goes Idle from the WCF host. If the client goes Idle from the WCF service, it will throw the below error.

    http://www.codeproject.com/KB/WCF/WCF_Operation_Timeout_.aspx

    你可以使用代码来修改
    (service, IContextChannel).OperationTimeout = New TimeSpan(0, 0, 240)


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
    欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
    欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
    欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum
    2010年1月11日 8:54
    版主

全部回复