I'm trying to determine whether a device on a network is running a web server or not using Java. To do this I'm using Apache's HttpClient. I send a request and if the device runs a web server I get a response - pretty simple.
However, if a web server is not running then I've observed 2 things happen:
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
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. Most will not have firewalls.
I also know with 100% certainty that the device is up and running.
You cannot infer anything with 100% certainty, but:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With