错误:ConnectFailure(无路由到主机) [英] Error: ConnectFailure (No route to host)

查看:91
本文介绍了错误:ConnectFailure(无路由到主机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:我有一个Xamarin.Android应用程序,它连接到WebAPI以获得不同的信息.

Context: I have a Xamarin.Android app that it connects to an WebAPI for different information.

问题:尝试访问服务器时,出现以下错误:

Issue: When trying to access the server I get the following error:

System.Net.Http.HttpRequestException:发送请求时发生错误---> System.Net.WebException:错误:ConnectFailure(无路由到主机)

System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (No route to host)

问题上下文:我们在同一网络中有2台服务器,配置相同(至少希望如此,位于客户端站点),如果我们使用相同的应用程序(相同的构建),则可以连接到服务器A,但是得到连接到B时出现上述错误.关于B服务器:我可以从设备浏览器访问 http://address/help 或/token页面,我还可以通过Google Play的"REST Api Client"发出所需的请求,并获得成功的响应.从我们的应用程序连接到服务器B时似乎唯一的问题.我们的环境中也不存在此问题(正如我提到的,A和B在客户端站点上.)

Issue context: we have 2 servers in the same network, configured the same (at least we hope so, is at client site) and if we use the same app (same build) we can connect to server A, but get the mentioned error when connecting to B. About the B server: I can access from device browser the http://address/help or /token page, I can also do the desired request from 'REST Api Client' from Google Play and get a successful response. The only problem it seems when connecting from our app to the server B. This issue is also not present on our environments (as I mentioned, the A and B are at client site).

问题:问题出在哪里,我们应该进一步看待什么?

Question: What would be the problem and where should we look further?

谢谢!

推荐答案

我在Xamarin表单上找到了这个答案,虽然不能解决我的问题,但也许对您有所帮助. https://forums.xamarin.com/discussion/70731/connection-error-no-route-to-host-only-happens-on-android

I found this answer on Xamarin forms, this didn't solve my problem, but maybe it could help in yours. https://forums.xamarin.com/discussion/70731/connection-error-no-route-to-host-only-happens-on-android

我遇到了这个问题,因为我没有处理我的HttpClient对象.第一个或第二个请求没有发生这种情况,但是从请求10开始,它将开始给我带来问题.尤其是当它们异步发生时.

I had this problem because I didn't dispose my HttpClient object. It didn't happen with the first or second request, however from request 10 it would start giving me problems. Especially when they were happening asynchronously.

我不知道这是否可以解决您的问题,因为这两者都是特例.也许您的情况也是如此.

I don't know if this will solve your problem, as both these seem to be a special case instance. Maybe yours is a special case as well.

这篇关于错误:ConnectFailure(无路由到主机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆