开发者

WCF Exception for long operations: netTcpBinding

开发者 https://www.devze.com 2023-03-14 13:07 出处:网络
We have the followin开发者_如何学Gog netTcpBinding in the service.In one particular scenario, we have a huge database operation that takes around 35 minutes to complete.I am getting “The socket conne

We have the followin开发者_如何学Gog netTcpBinding in the service. In one particular scenario, we have a huge database operation that takes around 35 minutes to complete. 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. What are the config values for which default value is 10 minutes?

Framework: .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.

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. The WCF is hosted in windows service

    <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


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. You will need to increase this. However, are you making a synchronous call for 35 minutes?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号