gpt4 book ai didi

c# - "The underlying connection was closed: An unexpected error occurred on a send."WebClient.OpenRead 错误(字符串链接)

转载 作者:行者123 更新时间:2023-11-30 19:24:21 25 4
gpt4 key购买 nike

我遇到错误“基础连接已关闭:发送时发生意外错误。”在获取 google API 的返回数据时。
在本地很好,但我已经发布并上传到服务器,我遇到了那个错误。请帮帮我..最好的问候...

 WebClient webClient = new WebClient();
Stream stream = webClient.OpenRead("https://www.googleapis.com/oauth2/v1/userinfo?access_token=[Access_Token]);
string b;

/*I have not used any JSON parser because I do not want to use any extra dll/3rd party dll*/
using (StreamReader br = new StreamReader(stream))
{
b = br.ReadToEnd();
}

最佳答案

您的连接正在连接到 HTTPS 端点,它可能需要 TLS 1.2,这可能不是您客户端的默认 TLS 版本;这是对旧版本 .NET 的修复:

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

关于c# - "The underlying connection was closed: An unexpected error occurred on a send."WebClient.OpenRead 错误(字符串链接),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38137244/

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