Twitter API响应“远程主机强行关闭了现有连接" [英] Twitter API responds with 'An existing connection was forcibly closed by the remote host'

查看:44
本文介绍了Twitter API响应“远程主机强行关闭了现有连接"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司有一些dotNET代码,在过去三个月中,他们一直在愉快地与Twitter的API通讯,以发布新闻.

My company had some dotNET code which has been talking to Twitter's API happily over the last three months, tweeting our news out.

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

On 29th July it stopped working, and the POST request was hit with this error:
An existing connection was forcibly closed by the remote host
System.Net.Sockets.SocketException

我认为这是因为我们的服务器仍在使用TLS 1.1,而我只是发现

I assume this is because our server is still using TLS 1.1 and I only just found this Twitter API announcement from June, which says:

自2014年删除SSL支持104以来,Twitter API已所有传入连接至少需要TLS 1.0.两者TLS1.0和1.1在2008年被TLS 1.2取代.

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.

从2019年7月25日开始,所有与Twitter API的连接(以及所有其他Twitter域)将要求使用TLS 1.2.此更改将影响API的所有格式和层(REST,流和Webhooks;标准,高级,企业以及广告和媒体API),以及更广泛的Twitter平台.

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日之间没有问题.

It seems we got 4 days grace, as our code had no problems between 25th and 28th July.

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

I believe the server itself has TLS 1.2 installed, so perhaps the issue is that this project was compiled with dotNET 4.0 which defaults to using TLS 1.1?

将我们的项目升级到dotNET 4.5可以解决问题,还是其他呢?

推荐答案

我来安装dotNET 4.5,并获得了修复/删除的选项,表明它已安装!这是出乎意料的.

I came to install dotNET 4.5 and was given the options to repair/remove, indicating it was already installed! This was unexpected.

所以我添加了以下代码行:
System.Net.ServicePointManager.SecurityProtocol = 3072

So I added this line of code:
System.Net.ServicePointManager.SecurityProtocol = 3072

并将Web.config更改为使用 targetFramework ="4.5"

And changed Web.config to use targetFramework="4.5"

现在一切正常.谢谢.

这篇关于Twitter API响应“远程主机强行关闭了现有连接"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆