我正在使用 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/