Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Run IoT GW as a service #1532

Closed
cowherdboy opened this issue Sep 21, 2024 · 5 comments
Closed

Unable to Run IoT GW as a service #1532

cowherdboy opened this issue Sep 21, 2024 · 5 comments
Assignees

Comments

@cowherdboy
Copy link

Describe the issue
I am using Thingsboard ver 3.6.0. I recently updated IoT Gateway from 3.0.1 to 3.5.1 when 3.0.1 stopped working. I noticed that when I run 3.5.1 as a service there is no data. However, when I run at the command line, i.e. sudo thingsboard-gateway I get the data without any issue. I am also not seeing anything being logged anymore even when I run as a service or from command line. I have attached my conf files.

Configuration (Attach your configuration file)
Attached

Connector name (If you need help with some connector/converter):
Modbus Connector

Error traceback (If it was raised):
sudo service thingsboard-gateway status
● thingsboard-gateway.service - ThingsBoard Gateway
Loaded: loaded (/etc/systemd/system/thingsboard-gateway.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2024-09-21 08:27:27 +08; 6min ago
Main PID: 3844 (python3)
Tasks: 22 (limit: 9345)
Memory: 67.5M
CPU: 3.188s
CGroup: /system.slice/thingsboard-gateway.service
├─3844 /usr/bin/python3 -c "from thingsboard_gateway.tb_gateway import daemon; daemon()"
└─3967 /usr/bin/python3 -m pip install pymodbus==3.0.0 --force-reinstall --user

Sep 21 08:33:37 INTRAIOT02 python3[3844]: module_spec.loader.exec_module(module)
Sep 21 08:33:37 INTRAIOT02 python3[3844]: File "", line 883, in exec_module
Sep 21 08:33:37 INTRAIOT02 python3[3844]: File "", line 241, in _call_with_frames_removed
Sep 21 08:33:37 INTRAIOT02 python3[3844]: File "/usr/lib/python3/dist-packages/thingsboard_gateway/connectors/modbus/modbus_connector.py", line 47, in
Sep 21 08:33:37 INTRAIOT02 python3[3844]: TBUtility.install_package("pymodbus", required_version, force_install=force_install)
Sep 21 08:33:37 INTRAIOT02 python3[3844]: File "/usr/lib/python3/dist-packages/thingsboard_gateway/tb_utility/tb_utility.py", line 161, in install_package
Sep 21 08:33:37 INTRAIOT02 python3[3844]: result = check_call(
Sep 21 08:33:37 INTRAIOT02 python3[3844]: File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
Sep 21 08:33:37 INTRAIOT02 python3[3844]: raise CalledProcessError(retcode, cmd)
Sep 21 08:33:37 INTRAIOT02 python3[3844]: subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'install', 'pymodbus==3.0.0', '--force-reinstall', '--user']' returned non-zero exit status 1.

Versions (please complete the following information):

@cowherdboy
Copy link
Author

I did a clean uninstall:
sudo apt remove python3-thingsboard-gateway

And reinstalled:
sudo apt install ./python3-thingsboard-gateway.deb -y

I am now getting the logs but my modbus data is still not coming in. I am attaching the logs + the status output which I dumped to the file, tb_screen.log & tb_screen2.log

service.log
tb_connection.log
tb_screen.log
tb_screen2.log

sudo thingsboard-gateway still works.

@imbeacon
Copy link
Member

Hi @cowherdboy,

Thank you for your interest in ThingsBoard IoT gateway, it looks like the gateway cannot get access to pypi repository to get modbus library. Please check your internet connection, getting libraries will be done only once, at first run of the connector.

@imbeacon
Copy link
Member

Also, please try to use the version 3.5.2, we have changed the package building logic and added virtual environment for required libraries

@cowherdboy
Copy link
Author

Hi @imbeacon,

Looks like there is a connectivity issue when running as a service. There is no issue when running from the command line for version 3.5.1 but for 3.5.2 I get the following error:

sudo thingsboard-gateway
Traceback (most recent call last):
File "/usr/local/bin/thingsboard-gateway", line 5, in
from thingsboard_gateway.tb_gateway import daemon
ModuleNotFoundError: No module named 'thingsboard_gateway'

When trying to run as a service 3.5.2 does not work either. I am attaching the log. I have now switched back to 3.5.1 as I can still run from the command line. As shown in the service.log I see the following error when running as a service:
2024-09-27 12:54:21 - |WARNING| - [tb_updater.py] - tb_updater - check_for_new_version - 92 - Cannot connect to the update service. PLease check your internet connection.

But not so when running on command line as you can see in the logs. How do I troubleshoot this connectivity when running as a service? Perhaps it is some firewall setting?

tb_connection.log
service.log

@cowherdboy
Copy link
Author

I have resolved the issue. It was due to proxy settings not configured in the service configuration file. You can get the proxy settings by:

echo $http_proxy
&
echo $https_proxy

Then add the resulting output to the service configuration file, i.e.
Edit the file:
sudo systemctl edit thingsboard-gateway.service

Add the following:
[Service]
User=thingsboard_gateway
Environment="http_proxy=http://x.x.x.x:yy/"
Environment="https_proxy=http://x.x.x.x:yy/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants