openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

Network Health Binding is quite unrealiable #2256

Closed sercasyr closed 8 years ago

sercasyr commented 9 years ago

Hi,

I have several network devices, and I would like to check their status. I use NH (Network Health) but it doesn't work well.

Some of the devices are displayed correctly, but others show always OFF. There are no firewalls, and all the devices answer to Ping, but NH simply does not work.

My configuration is very simple

Switch swRouter (grRed) {nh="192.168.1.1"} Switch swSwitch (grRed) {nh="192.168.1.3"} Switch swKNXIP (grRed) {nh="192.168.1.10"} Switch swRaspberryPi (grRed) {nh="192.168.1.12"} Switch swPC (grRed) {nh="192.168.1.50"}

The router and the RaspPI are correctly displayed. The Switch, the PC and the KNX-IP gateway are not. They all answer to Ping.

I am pretty sure the NH binding has a serious issue, because I read a previous issue commenting something similar, but I wasn't able to find the solution. Anyone has any solutions?

paulianttila commented 9 years ago

Hi,

network health binding doesn't use ICMP echo (ping) to test network device, but tries to open tcp connection device. By default binding use tcp port 80 to test connection (you can configure port to item configuration). So most probably you switch nor KNX-IP gateway does not response to port 80 and they seems to be off. If you don't know, does your device listening any tcp port which could be used to test connection, you can use e.g. nmap (linux) to scan all available ports of your device. If you device does not listen any TCP port you can use exec binding to execute ping command.

-Pali

2015-03-08 11:27 GMT+02:00 sercasyr notifications@github.com:

Hi,

I have several network devices, and I would like to check their status. I use NH (Network Health) but it doesn't work well.

Some of the devices are displayed correctly, but others show always OFF. There are no firewalls, and all the devices answer to Ping, but NH simply does not work.

My configuration is very simple

Switch swRouter (grRed) {nh="192.168.1.1"} Switch swSwitch (grRed) {nh="192.168.1.3"} Switch swKNXIP (grRed) {nh="192.168.1.10"} Switch swRaspberryPi (grRed) {nh="192.168.1.12"} Switch swPC (grRed) {nh="192.168.1.10"}

The router and the RaspPI are correctly display. The switch and the KNX-IP gateway are not. They both answer to Ping.

I read a previous issue commenting something similar, but I wasn't able to find the solution. Any solutions?

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2256.

sercasyr commented 9 years ago

The KNX gateway works on 3671. I also tried:

Switch swKNXIP (grRed) {nh="192.168.1.10:3671"}

and it didn't work either.

In any case, why can't the Network health do something similar to a PING??? Some of the devices are not servers listening for connections...

paulianttila commented 9 years ago

In any case, why can't the Network health do something similar to a PING

Java doesn't provide ICMP echo interface directly. Java have isReachable https://docs.oracle.com/javase/6/docs/api/java/net/InetAddress.html#isReachable(int) method since java 5, which should use ICMP echo if privilege can be obtained, otherwise it tries to use echo protocol to TCP port 7.

2015-03-08 12:43 GMT+02:00 sercasyr notifications@github.com:

The KNX gateway works on 3671. I also tried:

Switch swKNXIP (grRed) {nh="192.168.1.10:3671"}

and it didn't work either.

In any case, why can't the Network health do something similar to a PING??? Some of the devices are not servers listening for connections...

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2256#issuecomment-77742941.

sercasyr commented 9 years ago

Ok. I guess I just can't do what I need with NH binding. I understand the port 80 thing, but it should work on 3671 and it doesn't either...

Can I use the exec binding with Windows and map it to a OpenHAB switch item?? I am not using Linux...

J-N-K commented 9 years ago

Are you sure the KNX gateway responds to 3671/TCP? Mine is using 3671/UDP. The binding only checks the TCP port. I'll look into that as it annoys me, too.

sercasyr commented 9 years ago

I am sure is port number 3671. I am not sure if it's TCP or UDP. Maybe it's UDP, but it should be possible to check UDP too...

J-N-K commented 9 years ago

I fully agree. It should be quite easy to enhance the binding to support UDP. However, that does not provide an universal easy-to-use-solution.

Oracle should really allow RAW sockets.

J-N-K commented 9 years ago

I would appreciate some input: should it be configurable whether TCP or UDP is used or should we try TCP and if that fails UDP? The latter is more convinient, especially for those who do not do networking everyday.

Or perhaps a mixture of both:

foo.bar:1234:UDP

will check port 1234 with UDP (or TCP if specified) and

foo.bar:1234

will check UDP and TCP.

paulianttila commented 9 years ago

UDP is connectionless protocol, so it can't tested like TCP connections. Only way to test UDP connections is to send data to server and receive something from the server. In fact, send will always success even server is not reached, so binding should receive response from server to make decision is connection ok or not. This can't be done without knowing application protocol used over the UDP connection.

J-N-K commented 9 years ago

You are right. I was thinking about sending a packet and waiting for a response, but that will most probably fail if the sent packet was malformed for that service. Too early in the morning...

sercasyr commented 9 years ago

Ooops. It's true. So I guess I am stuck with the issue.

Given the limitations of NH, can we use something else? I can't believe there isn't a way to do a ping with OpenHab somehow... (exec binding for instance, although I don't use Linux..)

Any ideas?

teichsta commented 9 years ago

Hi,

for the KNX Binding you could simple let KNX regularly update a heartbeat DateTime Item in openHAB (DCF77 from my weather station). A simple rule can check whether the heartbeat DateTime is within a given range. This method does not only check the network availability but also the “protocol/binding healthiness”

Best, Thomas E.-E.

On 08 Mar 2015, at 12:21, sercasyr notifications@github.com wrote:

Ok. I guess I just can't do what I need with NH binding. I understand the port 80 thing, but it should work on 3671 and it doesn't either...

Can I use the exec binding with Windows and map it to a OpenHAB switch item?? I am not using Linux...

— Reply to this email directly or view it on GitHub https://github.com/openhab/openhab/issues/2256#issuecomment-77744080.

sercasyr commented 9 years ago

Thanks, but that's a very partial solution. The KNX gateway is just one of the devices that are not correctly display. I have others.

What I need is something that works like a PING but I don't know how to do it...

steve-bate commented 8 years ago

Please continue the discussion in the communit forum. https://community.openhab.org/t/networkhealth-unable-to-detect-some-devices/2902. Thanks!

mstuebner commented 8 years ago

Hi, all written here sounds logical, but in that case the documentation is just wrong:

"...where the parts in [] are optional. If no port is configured a simple ping is issued." (https://github.com/openhab/openhab/wiki/Network-Health-Binding)

I quickly checked this using Wireshark and found that even without a port number destination port=7 is set. So doc is wrong.

steve-bate commented 8 years ago

Port 7 is the Echo service. The Java networking code will automatically try to use that service if ICMP is not available for some reason (e.g., permissions). Please see the previously referenced community forum discussion for more details. I've just added similar information to the wiki.