gpt4 book ai didi

c# - 异常 : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

转载 作者:太空宇宙 更新时间:2023-11-03 15:15:52 25 4
gpt4 key购买 nike

我正在尝试使用 HTTPClient 调用 API,但出现标题中提到的异常。

经过 stackoverflow 的一些研究后,我发现在服务调用之前添加这一行可以解决问题

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

但此人没有解释这一行的原因,也没有说明这一行是否会影响程序的任何其他部分。

注意:我连接的服务器使用 https。

提前致谢。

最佳答案

来自MSDN在文章中您会发现必须在对 HTTPS 端点进行任何调用之前设置此属性。

This property selects the version of the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocol to use for new connections that use the Secure Hypertext Transfer Protocol (HTTPS) scheme only; existing connections are not changed. Note that no default value is listed for this property, on purpose. The security landscape changes constantly, and default protocols and protection levels are changed over time in order to avoid known weaknesses. Defaults will vary depending on individual machine configuration, and on which software is installed, and on which patches have been applied.

关于c# - 异常 : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46092544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com