.net - Twitter API 响应 'An existing connection was forcibly closed by the remote host'

标签 .net twitter tls1.2

我的公司有一些 dotNET 代码,在过去三个月里,它们一直在与 Twitter 的 API 愉快地通信,在 Twitter 上发布我们的新闻。

7 月 29 日,它停止工作,并且 POST 请求遇到以下错误:
现有连接被远程主机强制关闭
System.Net.Sockets.SocketException

我认为这是因为我们的服务器仍在使用 TLS 1.1,而我刚刚找到 this Twitter API announcement从六月开始,其中说:

Since the removal of SSL support 104 in 2014, the Twitter API has required a minimum of TLS 1.0 for all incoming connections. Both TLS 1.0 and 1.1 were superseded by TLS 1.2 in 2008.

Beginning July 25th 2019, all connections to the Twitter API (and all other Twitter domains) will require TLS 1.2. This change will affect all formats and tiers of the API (REST, streaming, and webhooks; standard, premium, enterprise, and Ads and Media APIs), as well as the wider Twitter platform.

我们似乎获得了 4 天的宽限期,因为我们的代码在 7 月 25 日至 28 日期间没有出现任何问题。

我相信服务器本身已安装 TLS 1.2,所以问题可能是该项目是使用 dotNET 4.0 编译的,默认使用 TLS 1.1?

将我们的项目升级到 dotNET 4.5 是否可以解决问题,或者可能是其他问题?

最佳答案

我从 7 月 29 日开始也遇到了同样的问题。我的项目是使用 .NET 4.5.2 编译的,并使用 LinqToTwitter 库。我可以通过在调用 Twitter 电话之前添加以下行来解决该问题。

System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;

关于.net - Twitter API 响应 'An existing connection was forcibly closed by the remote host',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57271345/

相关文章:

.net - 监控数据库中的表

.net - 我如何了解基于 .net 的应用程序正在使用哪个版本的 dotnet?

javascript - 使用 Javascript 对 Twitter 进行 Pin 授权

amazon-web-services - AWS 网络负载均衡器 SSL 直通

java - 如何在我的 android studio 应用程序中实现 TLS V1.1 和 V1.2?

mqtt - 为什么 HAProxy 在 TLS 握手结束时关闭与 HiveMQ MQTT 客户端的连接?

.net - ninject 被视为容器吗?

c# - 将 TabControl 绑定(bind)到 ViewModel 集合

php - 在将 Twitter 状态输出到网页之前,是否需要对其进行格式化?

twitter - 使用 Twitter API 检查谁阻止了您