I’m running openHAB 2.4.0 Build #1322 within a docker container for two weeks and suddenly my Zwave and Zigbee USB dongles no longer work. Karaf shows these messages:
RXTX fhs_lock() Error: opening lock file: /var/lock/LCK…ttyUSB0: File exists. It is mine
0 k testRead() Lock file failed
RXTX fhs_lock() Error: opening lock file: /var/lock/LCK…ttyACM0: File exists. It is mine
0 k testRead() Lock file failed
Have restarted openHab, restarted my Synology NAS with no luck.
USB devices are present, docker runs in highes access level mode. The permissions on /dev/ttyUSB0 and /dev/ttyACM0 are ok.
So I really don’t understand why this is happening? Any ideas?
I have seen this occasionally using snapshot 1325, but I never got to the bottom of it. I think it was an OH restart that resolved it for me. Did you try restarting the container, or is it setup to restart when the NAS reboots? Not much info for you, but you’re not alone!
I had been running OH as root when seeing this, but I recently changed to using an opehab account and found an issue that could be related. I mentioned this here. Check the permissions of /run/lock to see if the account running OH can’t write the lock file. If not, here is what I did…
Temporarily change group owner of /run/lock and add group write permission to see if this fix will work for you
#chown root:lock /run/lock
#chmod g+w lock
The /run/lock is recreated after each restart, so you need to make this change to set the group owner of /run/lock and add the group write permission:
#vi /usr/lib/tmpfiles.d/legacy.conf
Look for this line:
d /run/lock 0755 root root -
Comment it out (add a hash symbol before it) and insert a new line with:
d /run/lock 0775 root lock -
Save. Restart openHAB and verify functionality. Upon reboot, the permissions on /run/lock should be set with ownership root:lock and permission mask 775. I’m still investigating this, but I think it may be a new issue. I’m currently on 1330 and have not seen this issue again.
I’m running openhab from docker on a Synology NAS. The openhab container runs with high privilege, so I take it runs with root. So do you think the same steps would apply to my environment?
I may be taking you down a rabbit hole. The actual error you are seeing means that the lock file was not cleaned up (OH not shutdown properly, power outage, etc.). Docker adds another layer to this. Try shutting down OH (not the container) properly with CTRL-D in Karaf. The lock files should be cleaned up. I think I had to install ssh for this when I was playing with the Docker image. I know you said you have restarted OH, but maybe you were just restarting the container or killing the Java pid? Another option is to manually delete the lock files before starting OH, after an improper shutdown.
Previously, I shutdown OH containter via Docker. Now I did some cleanshutdowns via karaf. The ‘LCK…ttyACM0’ lock file gets removed, but ‘LCK…ttyUSB0’ isnt. I list the files thru karaf with ‘shell:ls’:
I first want to try to delete ‘LCK…ttyUSB0’ as it looks like that one doenst get deleted. Karaf and shell doenst seem to have a way to delete files. Do you know other way to do this? Enable SSH in the container?
Checked with Karaf, and the file dates match. When I shutdown OH, the lock files do get deleted. So I think the origen of the problem is not that the files already exist.
This looks like it may be an ESH issue with nrjavaserial, but possibly with Docker factors in play. Snapshot build 1330 has ESH 0.10.0.201808130936 and nrjavaserial 3.14.0, which was merged into ESH on July 5th. The previous version was 3.12.0. Which version of nrjavaserial do you have (in Karaf, list |grep serial)? Maybe you could try an earlier snapshot, or 2.3 to see if the error occurs there too?
There’s definitely no problem with /var/lock (/run/lock) permissions, as I test openhab2 as openhab user with correct permissions and root (no difference). I even removed the symlink and created /var/lock with 777.
I’m testing with fresh installs (purge /opt/openhab2/, download, extract, run, enable zwave binding, add controller, discover) while having an eye on /var/lock
M1 was done on Aug 15 and M2 on Aug 28, so you might want to check the snapshots between those dates - I am just not sure, if those are still anywhere available. Here you can see the changes between the two milestones.
As this happens with Z-Wave dongles, maybe @chris has any input on the issue?