[英]Difference between a “Connection Refused” exception and a timeout in HttpClient
I'm trying to determine whether a device on a network is running a web server or not using Java. 我正在尝试确定网络上的设备是否正在运行Web服务器或不使用Java。 To do this I'm using Apache's HttpClient.
为此,我使用的是Apache的HttpClient。 I send a request and if the device runs a web server I get a response - pretty simple.
我发送一个请求,如果设备运行Web服务器,我会得到响应-非常简单。
However, if a web server is not running then I've observed 2 things happen: 但是,如果Web服务器未运行,那么我观察到发生了两件事:
An exception will be thrown. 将引发异常。 In particular, it will look like this:
特别是,它看起来像这样:
org.apache.http.conn.HttpHostConnectException: Connect to 192.168.12.133:80 [/192.168.12.133] failed: Connection refused: connect org.apache.http.conn.HttpHostConnectException:连接到192.168.12.133:80 [/192.168.12.133]失败:连接被拒绝:connect
Is there anything that can be inferred about the device that I'm trying to connect to when I receive the "Connection refused" exception vs. getting no response at all? 当我收到“拒绝连接”异常与完全没有响应时,是否可以推断出我要连接的设备的任何信息?
Edit: 编辑:
Just to clarify: What I'm doing is running this against DEVICES on a local network. 只是要澄清一下:我正在做的是针对本地网络上的设备运行此操作。 That means NAS boxes, routers, Windows computers, iPads, etc. Some will have embedded web servers, others will not.
这意味着NAS盒,路由器,Windows计算机,iPad等。有些将带有嵌入式Web服务器,而有些则没有。 Most will not have firewalls.
大多数将没有防火墙。
I also know with 100% certainty that the device is up and running. 我还以100%的把握知道设备已启动并正在运行。
You cannot infer anything with 100% certainty, but: 您无法100%确定地推断任何内容,但是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.