timeout - WCF 超时问题?

标签 timeout azure wcf wcf-client

我有一个基于 WCF 的流程,耗时较长。 WCF 服务在 Azure 中运行(如果有帮助的话)。我认为问题与超时有关:

1) Winforms 客户端在绑定(bind)部分具有以下 .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 中有以下绑定(bind)部分

   <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 秒后终止空闲连接。

关于timeout - WCF 超时问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4858800/

相关文章:

timeout - jedis pubsub 和超时 : how to listen infinitely as subscriber?

c# - 如果没有发送数据,TCP 套接字会在一段时间后自动关闭吗?

html - XDocument 是否适合生成 HTML?

wcf - 使用 WCF 的 basicHttpBinding 进行 Windows 身份验证

c# - WCF 中 MSI 包的自动更新

error-handling - power bi 报表服务器计划刷新错误

java - 如何为 c3p0 设置 getConnection() 超时?

azure - .net core web api 在发布到 azure 时响应 500

database - 通过现有数据库还原 Azure SQL DB 以维护备份历史记录

python - Azure Pipelines - 使用 Poetry 的正确方法