“底层连接已关闭:预期保持活动状态的连接已被服务器关闭"调用 SOAP 时 [英] "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server" when calling SOAP

查看:35
本文介绍了“底层连接已关闭:预期保持活动状态的连接已被服务器关闭"调用 SOAP 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时在调用另一个 WSDL 服务时收到错误底层连接已关闭:服务器关闭了预期保持活动的连接".

I sometimes got error "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server" when calling another WSDL service.

我使用 .Net 4.5 WCF 服务,我的应用程序连接到外部 3rd 方 SOAP-WSDL 服务以执行操作.对该服务的大部分调用都成功完成,但有一个特定调用,其中 5% 的调用因该错误而失败

I use .Net 4.5 WCF service, My application connect to external 3rd party SOAP-WSDL service to perform actions. most of calls to this service done successfully, but there is one specific call, 5% of that calls are failed with that error

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server

下面是该服务的 bindingConfiguration

Below is the bindingConfiguration for that service

<bindings>
      <customBinding>
        <binding name="AnotherServiceSoap12Binding" openTimeout="01:30" receiveTimeout="01:30" sendTimeout="01:30" closeTimeout="01:30">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="999999" />
          </textMessageEncoding>
          <httpTransport manualAddressing="false" 
            allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" 

                maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
            proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
        </binding>
      </customBinding>
    </bindings>

我还从日志中注意到连接没有超时,在该错误出现之前大约需要不到 10 秒.

Also I notice from logs that the connection not timeout, it takes around less than 10 seconds before that error comes.

知道问题出在哪里,或者我如何获得更多数据来检测问题的根本原因.我还需要知道修复程序应该来自我的客户端应用程序还是来自 3rd 方服务.

Any idea what is the problem, or how could I get more data to detect the root cause of it. also I need to know if the fix should come from my client application or from the 3rd party service.

推荐答案

您应该检查您的客户端端点绑定的客户端配置 openTimeout="01:30" receiveTimeout="01:30" sendTimeout="01:30" closeTimeout="01:30" 与您的第 3 方服务相同,您的运输需要满足双方的要求.

You should check if the client config for your client endpoint binding openTimeout="01:30" receiveTimeout="01:30" sendTimeout="01:30" closeTimeout="01:30" is the same for your 3rd party service and also your transport need to meet the required requirement for both side.

<httpTransport manualAddressing="false" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"            proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />

当客户端超时大于服务器超时时,会发生此错误.为了避免这个错误,你的 receiveTimeout 和 sendTimeout 应该增加.

This error happens, when the client time out is greater than the server's time out. To avoid this error your receiveTimeout and sendTimeout should be increased.

这篇关于“底层连接已关闭:预期保持活动状态的连接已被服务器关闭"调用 SOAP 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆