"no such host is known" 在 system.http 中将端点连接到网络 api
"no such host is known" in system.http hitting endpoint to web api
我重新格式化了我的电脑,提取了我的项目并试图达到终点。
我有 2 个网络 api,一个 运行 在 localhost:8071,一个在 localhost:8072。
达到 8071 构建和调试就好了。在 localhost:8072 上击中第二个网络 api,我在终点没有击中断点!
打开异常设置后,我只能看到 API 中的一个异常,如下所示。
我得到的错误是 "No such host is found",它在 System.Private.CoreLib
堆栈跟踪:
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
完全异常:
- [0] {System.Net.Http.HttpRequestException: No such host is known ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)} System.Exception {System.Net.Http.HttpRequestException}
我认识的其他人已经提取了代码并且在加载网络 api 和访问端点时没有任何问题。
全新安装应该可以修复它,所以不确定为什么仍然会发生这种情况。
我是运行.NET core 2.1.
我试过更改端口无济于事。此外,所有防火墙都已关闭。不确定为什么网络 api 项目之一可以达到终点而另一个不能。
谢谢
根本没有涉及自定义中间件。即使在另一个完整格式之后它也没有用。
通过将项目升级到 .NET core 2.2 SDK 设法解决了这个问题。
我重新格式化了我的电脑,提取了我的项目并试图达到终点。
我有 2 个网络 api,一个 运行 在 localhost:8071,一个在 localhost:8072。
达到 8071 构建和调试就好了。在 localhost:8072 上击中第二个网络 api,我在终点没有击中断点!
打开异常设置后,我只能看到 API 中的一个异常,如下所示。
我得到的错误是 "No such host is found",它在 System.Private.CoreLib
堆栈跟踪:
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
完全异常:
- [0] {System.Net.Http.HttpRequestException: No such host is known ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)} System.Exception {System.Net.Http.HttpRequestException}
我认识的其他人已经提取了代码并且在加载网络 api 和访问端点时没有任何问题。
全新安装应该可以修复它,所以不确定为什么仍然会发生这种情况。
我是运行.NET core 2.1.
我试过更改端口无济于事。此外,所有防火墙都已关闭。不确定为什么网络 api 项目之一可以达到终点而另一个不能。
谢谢
根本没有涉及自定义中间件。即使在另一个完整格式之后它也没有用。
通过将项目升级到 .NET core 2.2 SDK 设法解决了这个问题。