【问题标题】:Socrata : An existing connection was forcibly closed by the remote hostSocrata:远程主机强行关闭了现有连接
【发布时间】:2016-12-01 22:53:38
【问题描述】:

我创建了一个应用程序,它会定期(每月的第一个星期日)向 data.cms.gov 发送请求以检查 pecos 注册医生。代码运行良好,但几天前停止工作。我收到此响应“无法从传输连接读取数据。现有连接被远程主机强行关闭。”谁以前遇到过这种情况,或者有人可以帮忙吗?我使用下面的代码作为我的请求

string end_point = "https://data.cms.gov/resource/qcn7-gc3g.json?$$app_token=myapp_token&npi=";
string cms_uri = end_point + npi;
System.Net.WebClient cms_wc = new System.Net.WebClient();
byte[] bResponse = cms_wc.DownloadData(cms_uri);
string cms_response = System.Text.Encoding.ASCII.GetString(bResponse);

【问题讨论】:

    标签: c# c#-4.0 webclient socrata soda


    【解决方案1】:

    作为安全升级,我们已禁用 TLS 1.0 作为允许的 SSL 协议。我的猜测是,这就是触发您断开连接的原因。

    https://support.socrata.com/hc/en-us/articles/235267087

    您需要指示 .NET 使用 TLS 1.1 或 1.2。您应该能够通过在创建客户端之前添加以下内容来做到这一点:

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

    this issue on one of the C# .NET libraries for the SODA API 中有更多信息。

    【讨论】:

      猜你喜欢
      • 2017-12-22
      • 2021-05-12
      相关资源
      最近更新 更多