Closed helsmore closed 2 years ago
Hi @helsmore, this is an expected situation because you haven't installed pyserial
, so Gateway dynamically installs it but Python can't resolve it so you have to restart your Gateway.
See Release notes v.3.2, Modbus section.
Hi @samson0v, I'm pretty sure that I had to rename the serial
extension directory in /var/lib/thingsboard_gateway
to myserial
to solve the problem, restarting the service wasn't enough by itself to fix the problem, but I'll do a clean re-installation to confirm.
Also this doesn't solve the first part of the issue, where I need to rename the socket
extension directory in /var/lib/thingsboard_gateway
to mysocket
to get the service to start at all after installation (as described in first post), that part of the problem occurred before I enabled the Modbus connector.
You can see for example in the second set of logs the AttributeError: module 'serial' has no attribute 'serial_for_url'
error indicating that Python has imported a copy of the serial
module, but not the system one - I suspect it's imported the serial
extension from /var/lib/thingsboard_gateway
due to the service using that directory is its working directory.
My apologies, it seems like I may have had items left in /var/lib/thingsboard_gateway
from a previous installation that were causing the attribute error issues.
I used the following commands to cleanup and re-install:
sudo apt remove --purge python3-thingsboard-gateway
sudo rm -rf /var/log/thingsboard-gateway
sudo rm -rf /var/lib/thingsboard_gateway
sudo rm -rf /etc/thingsboard-gateway
sudo userdel -r thingsboard_gateway
sudo groupdel thingsboard_gateway
sudo reboot
sudo apt update && sudo apt full-upgrade
sudo apt install ./python3-thingsboard-gateway.deb -y
journalctl --follow -u thingsboard-gateway.service
sudo adduser thingsboard_gateway dialout
sudo mv /etc/thingsboard-gateway/config/tb_gateway.yaml /etc/thingsboard-gateway/config/tb_gateway.yaml.ORIG
sudo cp -a ~/tb_gateway.yaml.MOD /etc/thingsboard-gateway/config/tb_gateway.yaml
sudo cp -a ~/modbus_new_1.json.MOD /etc/thingsboard-gateway/config/modbus_new_1.json
sudo systemctl restart thingsboard-gateway.service
journalctl --follow -u thingsboard-gateway.service
After this cleanup and re-install the service was running fine and polling my Modbus RTU devices, no attribute errors in the logs.
Thanks for your help @samson0v, please also note that I didn't need to restart the service after the automatic installation of PyModbus
and pySerial
, it began working straight away.
Describe the bug The
systemd
service installed by the v3.2 Debian Installer fails at startup once the installation is completed and again when the gateway configuration has been setup.I suspect that the cause of the failure is that the extension folders are getting placed (by the installer) directly into
/var/lib/thingsboard_gateway
which is the working directory used when starting the service (rather than placing them in say anextensions
sub-directory), this means that import statements for (e.g.)socket
andserial
are resolving to the gateway extensions with these names thus shadowing the actual system packages with the same names and causing attribute errors and service restarts/failures.This seems very similar to a problem reported in a comment on a previous issue originally posted in https://github.com/thingsboard/thingsboard-gateway/issues/839#issuecomment-1163379504 by @ilseva and @wilterdinkrobert and indeed that's where I got the workaround listed for the first error from.
Connector name (If bug in the some connector): Modbus, but entire service cannot start even without the Modbus connector active.
Error traceback (If available): For error relating to
socket
, occurred immediately after installation completed:The workaround for this error to allow me to get the service to start at all was as follows:
After the above workaround I modified the configuration to point to my TB platform instance and activated the Modbus connector, I then got the following error relating to
PyModbus
importing the systemserial
module:The workaround to allow me to get the Modbus connector working was as follows:
After this the service worked correctly and data from my Modbus RTU device appeared in my TB platform instance.
Versions (please complete the following information):
Note that to get the service installed on Raspbian at all I had to follow the workaround I've listed in https://github.com/thingsboard/thingsboard-gateway/issues/975#issuecomment-1299919769 as the installer for the Thingsboard IoT Gateway has broken on Raspbian and Debian at the v3.2 release.