简体   繁体   English

httpclient 在公司代理中无法从 .net6 工作

[英]httpclient is not working from .net6 in corporate proxy

I have tried below -我在下面尝试过 -

Tried to fiddle with proxy and credentials for httpclient object creation.试图摆弄 httpclient object 创建的代理和凭据。 Checked the code executes outside VPN and doesn't Inside VPN.检查代码在 VPN 外部执行而不在 VPN 内部执行。 Tried downloading code from this repo and tried to replicate under my office proxy it doesn't work only for .net6 example.尝试从此 repo 下载代码并尝试在我的 office 代理下复制它不适用于 .net6 示例。 It is working for .net5 and below all the time.它一直适用于 .net5 及以下版本。 .net6 example I'm referring to AspNetCore.Docs/aspnetcore/fundamentals/http-requests/samples/6.x/HttpRequestsConsoleSample/ Tried degrading Microsoft.Extensions.Http package (from 6.0.0 to 2.1.1 and everything in between) in the sample code from this repo on .net6 example. .net6 示例我指的是 AspNetCore.Docs/aspnetcore/fundamentals/http-requests/samples/6.x/HttpRequestsConsoleSample/ 尝试降级 Microsoft.Extensions.Http ZEFE90A8E604A7C840E88D03A67F6B7D8.1.1 到 6 之间的所有内容在此 repo on .net6 示例的示例代码中。 No what matter I did .net6 httpclient.sendAsync method calls are always resulting in below errors.不管我做了什么 .net6 httpclient.sendAsync 方法调用总是导致以下错误。 Can someone please help.有人可以帮忙吗。

System.Net.Http.HttpRequestException: 'An error occurred while sending the request.' System.Net.Http.HttpRequestException:“发送请求时出错。”

IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.. IOException:无法从传输连接中读取数据:已建立的连接被主机中的软件中止。

SocketException: An established connection was aborted by the software in your host machine. SocketException:已建立的连接被主机中的软件中止。

I went ahead and added a runtimeconfig.template.json file to the project (.NET 6) with the following in it:我继续在项目(.NET 6)中添加了一个 runtimeconfig.template.json 文件,其中包含以下内容:

{
  "configProperties": {
    "System.Net.DisableIPv6": "true"
  }
}

And this resolved my issue.这解决了我的问题。

Source: https://github.com/dotnet/runtime/issues/62825来源: https://github.com/dotnet/runtime/issues/62825

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM