thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.74k stars 844 forks source link

Unable to run tb_gateway.py #1469

Closed rock-007 closed 3 months ago

rock-007 commented 3 months ago

Describe the bug I have been following this guid(https://thingsboard.io/docs/iot-gateway/install/source-installation/) to run the GW locally, I have successfully run the backend springboot application and when running this command it is having exception in the thread, is it some know bug or if some settings I need to teak for it to work?

Connector name (If bug in the some connector): not sure but it also say can't connect to GRPC connector!

Error traceback (If available):

`
'deviceName'
Traceback (most recent call last):
  ❯ python3 ./thingsboard_gateway/tb_gateway.py
Cannot load GRPC connector!
2024-07-18 14:57:19 - |INFO| - [tb_gateway_service.py] - tb_gateway_service - __init__ - 168 - Gateway starting...
2024-07-18 14:57:19 - |INFO| - [tb_gateway_service.py] - tb_gateway_service - __init__ - 171 - ThingsBoard IoT gateway version: 3.5.1
Exception in thread Thread-4 (_thread_main):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3637, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1769, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1177, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1569, in loop_read
    rc = self._packet_read()
         ^^^^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 2485, in _packet_read
    rc = self._packet_handle()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3075, in _packet_handle
    return self._handle_pubackcomp("PUBACK")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3565, in _handle_pubackcomp
    reasonCode.unpack(self._in_packet['packet'][2:])
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/reasoncodes.py", line 167, in unpack
    name = self.__getName__(self.packetType, c)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/umairashraf/Projects/Personal/thingsboard-gateway/venv/lib/python3.11/site-packages/paho/mqtt/reasoncodes.py", line 138, in __getName__
    assert identifier in self.names.keys(), identifier
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 47
2024-07-18 14:58:20 - |WARNING| - [tb_device_mqtt.py] - tb_device_mqtt - _publish_data - 745 - Waiting for connection to be established before sending data to ThingsBoard!
2024-07-18 14:58:30 - |WARNING| - [tb_device_mqtt.py] - tb_device_mqtt - _publish_data - 745 - Waiting for connection to be established before sending data to ThingsBoard!
`
KeyError: 'Exception in thread Thread-4 (_thread_main):'

Versions (please complete the following information):

rock-007 commented 3 months ago

so the above issue is resolved as the port number was the issue in the config file. Now I am facing another issue as its complaining about the user/password is wrong, I have add the access token in the thingsboard_gateway/config/tb_gateway.json

Note: Just to double check I have used the user/password of tenant@thingsboard.org/tenant & sysadmin@thingsboard.org/sysadmin, and got the access token using the browser network tab...

image
samson0v commented 3 months ago

Hi @rock-007, thanks for your interest in ThingsBoard IoT Gateway! You have to create a gateway on the device page and copy the access token from it. Also, I recommend you to read getting started guide.

rock-007 commented 3 months ago

Thanks @samson0v for the reply, yes I figured out last night about this step its in the general configuration/security section, Its working now. Thanks :)

lolPlatinumPlayer commented 2 months ago

so the above issue is resolved as the port number was the issue in the config file. Now I am facing another issue as its complaining about the user/password is wrong, I have add the access token in the thingsboard_gateway/config/tb_gateway.json

Note: Just to double check I have used the user/password of tenant@thingsboard.org/tenant & sysadmin@thingsboard.org/sysadmin, and got the access token using the browser network tab...

image

Hi, @rock-007 . I see Cannot load GRPC connector! in this Picture. Is it means its OK?