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

[BUG] MQTT RPC not handled - 'id' seems to be wrong #1222

Closed
KubaDavid opened this issue Nov 8, 2023 · 1 comment
Closed

[BUG] MQTT RPC not handled - 'id' seems to be wrong #1222

KubaDavid opened this issue Nov 8, 2023 · 1 comment
Assignees
Labels

Comments

@KubaDavid
Copy link

Describe the bug
I'm trying to send RPC in the following way "TB CE (RPC Button)" -> "TB IoT Gateway" -> "MQTT Broker" -> "Device". Unfortunately when I click the RPC button on my TB dashboard the command is not executed. TB IoT Gateway gets it but the 'id' of the RPC request is weird and triggeres error. As you can see in the traceback.
I see some changes made here: #1201

This is config of my RPC button on dashboard:
{ "method": "no-reply", "params": { "message": "Hello" } }

This is the IoT Gateways config:
{ "broker": { "name": "MQTT Broker TBMQ", "host": "127.0.0.1", "port": 1883, "clientId": "test-gateway", "version": 5, "security": { "type": "basic", "username": "user", "password": "pass" } }, "mapping": [ { "topicFilter": "platform/city/asset/+/data", "converter": { "type": "json", "deviceNameTopicExpression": "(?<=asset/)(.*?)(?=/data)", "deviceTypeTopicExpression": "asset", "timeout": 60000, "attributes": [ { "type": "string", "key": "model", "value": "Enceladus" } ], "timeseries": [ { "type": "bool", "key": "Q1", "value": "${Q1}" }, { "type": "bool", "key": "Q2", "value": "${Q2}" }, { "type": "bool", "key": "Q3", "value": "${Q3}" }, { "type": "bool", "key": "Q4", "value": "${Q4}" }, { "type": "bool", "key": "I1", "value": "${I1}" }, { "type": "bool", "key": "I2", "value": "${I2}" }, { "type": "bool", "key": "I3", "value": "${I3}" }, { "type": "int", "key": "B015", "value": "${B015}" }, { "type": "int", "key": "B197", "value": "${B197}" }, { "type": "int", "key": "Signal", "value": "${Signal}" } ] } } ], "connectRequests": [ { "topicFilter": "platform/city/asset/+/connect", "deviceNameTopicExpression": "(?<=sensor/)(.*?)(?=/connect)" } ], "disconnectRequests": [ { "topicFilter": "platform/city/asset/+/disconnect", "deviceNameTopicExpression": "(?<=sensor/)(.*?)(?=/disconnect)" } ], "attributeRequests": [ { "retain": false, "topicFilter": "v1/devices/me/attributes/request", "deviceNameJsonExpression": "${model}", "attributeNameJsonExpression": "${mode}", "topicExpression": "devices/${model}/attrs", "valueExpression": "${attributeKey}: ${attributeValue}" } ], "attributeUpdates": [ { "retain": true, "deviceNameFilter": "sn.*", "attributeFilter": "mode", "topicExpression": "platform/city/asset/${deviceName}/control", "valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}" } ], "serverSideRpc": [ { "deviceNameFilter": ".*", "methodFilter": "no-reply", "requestTopicExpression": "/platform/city/asset/${deviceName}/control", "valueExpression": "test" } ], "logLevel": "DEBUG", "name": "Test MQTT Broker" }

Connector name (If bug in the some connector):
mqtt_connector.py

Error traceback (If available):
Starkoc-TBGateway | 2023-11-08 20:49:08 - |INFO| - [mqtt_connector.py] - mqtt_connector - server_side_rpc_handler - 847 - Incoming server-side RPC: {'device': 'sn001', 'data': {'id': 36, 'method': 'rpcCommand', 'params': {'method': 'no-reply', 'params': {'message': 'Hello'}}}, 'id': <tb_gateway_mqtt.TBGatewayMqttClient object at 0x7fd8dc0c67d0>}
Starkoc-TBGateway | 2023-11-08 20:49:08 - |ERROR| - [mqtt_connector.py] - mqtt_connector - server_side_rpc_handler - 883 - RPC not handled: {'device': 'sn001', 'data': {'id': 36, 'method': 'rpcCommand', 'params': {'method': 'no-reply', 'params': {'message': 'Hello'}}}, 'id': <tb_gateway_mqtt.TBGatewayMqttClient object at 0x7fd8dc0c67d0>}

Versions (please complete the following information):

  • OS: Ubuntu, 22.04.2 LTS (Jammy Jellyfish)
  • Thingsboard IoT Gateway version 3.4.2
  • Python version - TB IoT Gateway run in official docker container
@samson0v
Copy link
Contributor

samson0v commented Nov 9, 2023

Hi @KubaDavid, thanks for your interest in ThingsBoard IoT Gateway!
Your connector can't connect to your MQTT broker because you run Gateway via the docker container.
You can add --network=host when you start your container.

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

No branches or pull requests

3 participants