简体   繁体   English

长操作的WCF异常:netTcpBinding

[英]WCF Exception for long operations: netTcpBinding

We have the following netTcpBinding in the service. 我们在服务中具有以下netTcpBinding。 In one particular scenario, we have a huge database operation that takes around 35 minutes to complete. 在一种特定的情况下,我们有一个庞大的数据库操作,大约需要35分钟才能完成。 I am getting “The socket connection was aborted” exception. 我收到“套接字连接已中止”异常。 What are the settings that I should change in order to avoid the exception? 为了避免异常,我应该更改哪些设置?

Note: I am getting the exception almost after 10 minutes. 注意:大约10分钟后,我得到了例外。 What are the config values for which default value is 10 minutes? 默认值为10分钟的配置值是什么?

Framework: .Net 3.0 框架:.Net 3.0

UPDATE : When I applied receiveTimeout="00:30:00", it is now saying the following IE error "The system cannot communicate with the external server " after some 5 minutes. 更新 :当我应用了receiveTimeout =“ 00:30:00”时,现在说了大约5分钟后,以下IE错误“系统无法与外部服务器通信”。

Before applying this, it used to be our aplications' custom error page. 在应用它之前,它曾经是我们应用程序的自定义错误页面。 Any idea what should I change now? 知道我现在应该更改什么吗?

Note: It is happening in the staging server. 注意:这是在登台服务器中发生的。 (The issue is not available in our dev env both before and after) (该问题在我们的开发环境中之前和之后均不可用)

Note: For Staging, the web application is hosted in IIS. 注意:对于暂存,Web应用程序托管在IIS中。 The WCF is hosted in windows service WCF托管在Windows服务中

    <bindings>

        <netTcpBinding>


            <binding name="AdministrationBinding" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="32" 
                    maxStringContentLength="2147483647" 
                    maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="16384"/>
            </binding>
        </netTcpBinding>

    </bindings>

The corresponding client side configuration is as follows: 相应的客户端配置如下:

    <binding name="NetTcpBinding_IAdministrationManager" 
             closeTimeout="00:30:00" 
             openTimeout="00:30:00" 
             receiveTimeout="00:30:00" sendTimeout="00:30:00" 
             transactionFlow="false" transferMode="Buffered" 
             transactionProtocol="OleTransactions" 
             hostNameComparisonMode="StrongWildcard" 
             listenBacklog="10"
             maxBufferPoolSize="524288" 
             maxBufferSize="2147483647" 
             maxConnections="10"     
             maxReceivedMessageSize="2147483647">

      <readerQuotas maxDepth="32" 
             maxStringContentLength="2147483647" 
             maxArrayLength="16384" maxBytesPerRead="4096" 
             maxNameTableCharCount="16384"/>

      <reliableSession ordered="true" 
             inactivityTimeout="00:30:00" enabled="false"/>

      <security mode="Transport">
        <transport clientCredentialType="Windows" 
             protectionLevel="EncryptAndSign"/>
        <message clientCredentialType="Windows"/>

      </security>

    </binding>

Thanks 谢谢

Lijo Lijo

You need to add the non-default values for the various timeouts on the server side as well. 您还需要在服务器端为各种超时添加非默认值。 Technically, not all timeouts are effective/useful on both sides (send vs. receive, open vs. close), but to keep things simple you can just mirror them on either side. 从技术上讲,并非所有超时都对双方都有效/有用(发送与接收,打开与关闭),但为使事情简单,您可以在任一端进行镜像。

Although you can increase the timeouts to stop this exception, long timeouts can cause other problems with your client waiting for ages before throwing an error if there is a problem. 尽管您可以增加超时来停止此异常,但是长时间的超时可能会导致其他问题,导致客户端等待年龄,如果有问题,则抛出错误。

I think it might be better to have the long operation happen asynchronously on the server, and have the method return immediately. 我认为让长时间操作在服务器上异步发生并让该方法立即返回可能会更好。 If you need notification on the client side of the operation's completion you can then use a callback. 如果需要在操作完成的客户端通知,则可以使用回调。

The receiveTimeout in the service defaults to 10 minutes - this is how long the service will wait for requests before deciding that a proxy has gone away. 服务中的receiveTimeout默认为10分钟-这是服务在确定代理消失之前将等待请求的时间。 You will need to increase this. 您将需要增加它。 However, are you making a synchronous call for 35 minutes? 但是,您是否要进行35分钟的同步通话?

For this scenario I would run everything asynchronously and either get the client to periodically check for completion or use duplex messaging and so the service informs the client when the operation is complete 对于这种情况,我将异步运行所有内容,或者让客户端定期检查是否完成,或者使用双工消息传递,因此服务在操作完成时会通知客户端

What ever happens, the client needs to talk to the service more often than the receiveTimeout otherwise the service will terminate the connection - and in fact if you use duplex then the service needs to talk to the client more often that the client's receiveTimeout for the same reason 无论发生什么情况,客户端都需要比该服务更频繁地与该服务进行对话,否则该服务将终止连接-实际上,如果您使用双工,则该服务需要更频繁地与该客户端进行对话,而同一个客户端的receiveTimeout原因

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

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