簡體   English   中英

WCF超時問題?

[英]WCF Timeout issue?

我有一個長期采用基於WCF的流程。 如果有任何幫助,WCF服務在Azure中運行。 我相信這個問題與超時有關:

1)Winforms客戶端在綁定部分中具有以下.config設置:

 <wsHttpBinding>
  <binding name="XXX" closeTimeout="00:05:00" openTimeout="00:05:00"
   receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
   transactionFlow="false" hostNameComparisonMode="StrongWildcard"
   maxBufferPoolSize="10000000" maxReceivedMessageSize="10000000"
   messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
   allowCookies="false">
   <readerQuotas maxDepth="255" maxStringContentLength="8192" maxArrayLength="16384"
    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
   <reliableSession ordered="true" inactivityTimeout="00:10:00"
    enabled="false" />
   <security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false"/>
   </security>
  </binding>
 </wsHttpBinding>

2)WCF服務在web.config中具有以下綁定部分

   <wsHttpBinding>
    <binding name="XXX" maxReceivedMessageSize="10000000" sendTimeout="00:10:00" receiveTimeout="00:10:00" closeTimeout="00:10:00" openTimeout="00:10:00">
     <security mode="TransportWithMessageCredential">
      <message clientCredentialType="UserName" establishSecurityContext="false" />
     </security>
     <readerQuotas maxArrayLength="2000000" maxBytesPerRead="10000000" maxStringContentLength="10000000" maxDepth="255" />
    </binding>

   </wsHttpBinding>

3)我在WCF中有一個長時間運行的方法(通常為2分鍾)。 客戶端調用該方法,執行時間超過1分鍾的客戶端將被拋出異常。 這是最內在的例外:

  <InnerException>
    <Type>System.Net.Sockets.SocketException</Type>
    <Message>An existing connection was forcibly closed by the remote host</Message>
    <StackTrace>
      <Frame>at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</Frame>
    </StackTrace>
  </InnerException>
</InnerException>

4)然而,WCF調用本身已成功完成(我在服務器端都記錄了開始/結束)。 我該如何避免異常?

謝謝!

Windows Azure負載均衡器在60秒后終止空閑連接。

更新的答案:

Azure負載均衡器在4分鍾后終止空閑連接。 如果您對增加/減少超時值感興趣,請查看以下文章:

https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM