c# - 向 https 发出 HTTP 请求时发生错误 -> 握手失败

标签 c# wcf basichttpbinding

我正在使用 basicHttpsbinding 的网络服务,如下所示

 EXCClient CreateClient()
    {
        var binding = new System.ServiceModel.BasicHttpsBinding();
        binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
        binding.MaxReceivedMessageSize = int.MaxValue;
        binding.UseDefaultWebProxy = false;
        var endpoint = new System.ServiceModel.EndpointAddress("https://{siteName}/{service}");

        var client = new EXCClient(binding, endpoint);
        return client;
        //return new EXCClient();
    }

消费站点托管在 IIS 7.5 上,并且在服务器上有多个站点。我正在使用 .net 表单站点,调用代码如下所示

var x = service.Client.GetResults({parameter});

运行此服务时将返回结果大约 15 分钟,然后开始出现此错误。

An error occurred while making the HTTP request to https://{siteName}/{service}/. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server

The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: The handshake failed due to an unexpected packet format.

如果我回收该站点的应用程序池,该服务开始再次返回结果大约 15 分钟,然后再次开始失败。我的应用程序池没有内存限制。

app.config 看起来像

<bindings>
    <basicHttpBinding>
        <binding name="BasicHttpBinding_EXC">
            <security mode="Transport" />
        </binding>
        <binding name="BasicHttpBinding_EXC1" />
    </basicHttpBinding>
</bindings>
<client>
    <endpoint address="https://vadrs.tax.utah.gov/vdx/" binding="basicHttpsBinding"
        bindingConfiguration="BasicHttpBinding_EXC" contract="UTVehicleServices.EXC"
        name="BasicHttpBinding_EXC" />
</client>

最佳答案

这个问题的答案在帖子“How do I disable SSL fallback and use only TLS for outbound connections in .NET? (Poodle mitigation)”中找到。我有其他 Web 服务调用设置了以下代码,没有回退

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

我必须按照回答帖子中的说明将协议(protocol)类型设置为 TLS。

关于c# - 向 https 发出 HTTP 请求时发生错误 -> 握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26764853/

相关文章:

javascript - 我的更新面板无法解锁

c# - 将文件上传详细信息转发到另一个远程服务

c# - WPF RightClick MouseBinding 发布?

wcf - 如何从 WCF 客户端访问 SOAP 1.1 故障详细信息(无故障契约(Contract))

c# - WCF,BasicHttpBinding : Stop new connections but allow existing connections to continue

c# - 绑定(bind)到位于 Xamarin 绑定(bind) Java 库中的服务

ios - 加密解密文本,兼容所有移动平台和wcf服务

c# - 单元测试 IExtension<OperationContext> 以用于 WCF 服务

c# - 在 Netbeans 中添加支持使用 WCF 流服务进行流处理的 Java Web 服务客户端?

c# - 从 WCF 代理的 basicHttpBinding 获取 HTTP 请求体