【问题标题】:WCF Getting "An error occurred while receiving the HTTP response to.." on random callWCF在随机调用中获取“接收HTTP响应时发生错误..”
【发布时间】:2017-07-23 17:39:02
【问题描述】:

我收到随机(不总是)“在从客户端调用 SOAP API 时收到 HTTP 响应时发生错误。”。它不会每次都发生。我的应用程序本身就是一个 WCF 服务。

客户端配置:

<binding name="AbcBinding" 
                 sendTimeout="00:02:45"
                 closeTimeout="00:02:45"
                 openTimeout="00:02:45"
                 receiveTimeout="00:10:00"
                 bypassProxyOnLocal="false"
                 maxBufferPoolSize="2147483647" 
                 maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="Transport" >
                <transport clientCredentialType="Basic" />
                </security>
        </binding>

<client>
      <endpoint binding="basicHttpBinding" bindingConfiguration="AbcBinding"
                contract="AbcContract" name="AbcBinding" />
    </client>

代码:

var configFactory = new ConfigurationChannelFactory<AbcContract>("AbcBinding"), ConfigFile, "localhost:9198/AbcCall");

            #region Basic http authentication
            if (configFactory.Credentials != null)
            {
                    var defaultCredentials = configFactory.Endpoint.Behaviors.Find<ClientCredentials>();
                    configFactory.Endpoint.Behaviors.Remove(defaultCredentials);

                    var loginCredentials = new ClientCredentials();
                    loginCredentials.UserName.UserName = "UserName";
                    loginCredentials.UserName.Password = "Password";
                    configFactory.Endpoint.Behaviors.Add(loginCredentials);

            }

编辑 在本地环境中,使用以下配置可以正常工作:useDefaultWebProxy="false" proxyAddress="http://127.0.0.1:8888"

但是在部署服务器上,上面的配置出现以下错误:

在...处没有可以接受消息的端点监听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。

【问题讨论】:

  • 这听起来像是与服务器的连接不稳定。如果您运行连续 ping,它们中的任何一个会超时/被丢弃吗?

标签: wcf wcf-client .net-4.5.2 wcf-configuration


【解决方案1】:

“接收 HTTP 响应时发生错误..”当您的服务代码出现问题时,可能会发生此错误。

重新检查服务代码。

尝试在客户端和服务器中启用 svclog。跟踪日志可以提供一些想法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 2023-01-30
    • 1970-01-01
    相关资源
    最近更新 更多