Error: Could not find a gateway on given path '/dev/ttyUSB0', 0 ports available

Hi all,

I’m running OH 3.3.0 as Docker container on my QNAP. I’m trying to add the modbus USB adapter and I have followed the guide to ensure:

  1. the device is loaded with correct driver
  2. permission is set correctly (777 for now)
  3. Extra java options are passed to container (EXTRA_JAVA_OPTS=-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0)
  4. –device is added to the docker run command

The setup seems to work well except that when I restart container, it sometimes losses connection to the serial port with an error message “IOException Could not find a gateway on given path ‘/dev/ttyUSB0’, 0 ports available.” The error occurs randomly when I restart the container, and normally it get resolved by restarting the container again (or a couple of times). Once the connection to the ttyUSB0 succeeds, it never fails until next restart.

Not sure what could be the root cause but I’d very much like to make the restart more predictable. Any suggestion where to look is very much appreciated!

@somy

I’m not using a docker environment. But could it be that the device isn’t fully recognized by the system at the time when openHAB tries to start?

I had some rare cases with my Debian OS, that one of the serial devices was also not ready.
For Example: Z-Wave stick found, but USB-Serial adapter not.

Hopefully you find a way to solve it.
Stefan

Thank you for your reply! I think the problem is elsewhere, the device is ready and work fine but after restart it stops working. Thanks for your input anyways!

This sounds a little like the bug in nrjavaserial which is the library OH was using for serial connection. See here for more info.
I think the library may have been replaced in more recent openHAB version

1 Like

Make sure the openHAB has access to /dev/ttyUSB0.
I had to sudo chmod 777 it to get it to work.