C# 向https发出HTTP请求时出错->;握手失败
我使用C# 向https发出HTTP请求时出错->;握手失败,c#,wcf,basichttpbinding,C#,Wcf,Basichttpbinding,我使用basicHttpsbinding消费一个Web服务,如下所示 EXCClient CreateClient() { var binding = new System.ServiceModel.BasicHttpsBinding(); binding.ReaderQuotas.MaxArrayLength = int.MaxValue; binding.MaxReceivedMessageSize = int.MaxValue;
basicHttpsbinding
消费一个Web服务,如下所示
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分钟的结果,然后开始出现此错误
向https://{siteName}/{service}/发出HTTP请求时出错。这可能是因为在HTTPS情况下,服务器证书未正确配置为HTTP.SYS。这也可能是由于客户端和服务器之间的安全绑定不匹配造成的
基础连接已关闭:发送时发生意外错误。-->System.IO.IOException:由于意外的数据包格式,握手失败
如果我为该站点回收应用程序池,该服务将在大约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>
这个问题的答案在帖子“”中找到。我还有其他web服务调用,它们设置了以下代码,没有任何回退
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
我必须将协议类型设置为TLS,如回复帖子中所述