【问题标题】:.NET core azure function app restsharp restclient throw The SSL connection could not be established.NET core azure function app restsharp restclient throw 无法建立 SSL 连接
【发布时间】:2020-04-04 14:23:17
【问题描述】:

我有 .net core azure function app,

到目前为止,以下代码运行良好。

现在我收到了这个错误 -

无法建立 SSL 连接,请参阅内部异常。无法从传输连接读取数据:现有连接被远程主机强行关闭。

var client = new RestClient("https://test.salesforce.com/services/oauth2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.Parameters.Clear();
request.AddParameter("grant_type", "password");
request.AddParameter("username", "user");
request.AddParameter("password", "123");
request.AddParameter("client_id", "qw2");
request.AddParameter("client_secret", "23s");
response = client.Execute(request);

【问题讨论】:

  • 你能告诉我你是否可以在本地运行代码吗?
  • 我发现这是因为我们需要将 ipaddres range 添加到 salesforce 来解决这个问题,一旦完成让我再检查一次 :)
  • 既然您的问题已经解决,能否请您发布您的答案?它可以帮助更多的人。

标签: c# salesforce azure-functions restsharp rest-client


【解决方案1】:

只需添加@Neo 的评论作为帮助社区成员的答案:

我们需要将 ipaddres range 添加到 salesforce 中来解决这个问题。

【讨论】:

    【解决方案2】:

    在执行其余部分之前添加它

    System.Net.ServicePointManager.Expect100Continue = false;
    

    如果仍然出现错误,则通过不同的身份验证,下面的身份验证是基本的,如果您想要承载更改身份验证类型。

     client.Authenticator = new HttpBasicAuthenticator(Username), (Password);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-29
      • 2021-02-01
      • 2021-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多