Skip to content

[HELP] Modbus TCP “Connection refused” on ports at gateway start when using TCP slave devices #2019

@szdavid0504

Description

@szdavid0504

Describe the issue
I created 3 Modbus TCP slave devices in ThingsBoard Gateway. When I start the TB Gateway service, I get random “Connection refused” errors to the target host/ports. After a restart, sometimes one of them comes up, sometimes all three do — it feels non-deterministic.

What I expected to happen
All three Modbus TCP slave devices should start reliably on service start, without intermittent connection failures.

What actually happens
On service start I frequently see the errors above. If I restart the service, sometimes one device starts, sometimes all three, sometimes none. The behavio

Configuration (Attach your configuration file)
Configuration (one of the 3 similar slave blocks):
{
"master": {
"slaves": []
},
"slave": {
"type": "tcp",
"host": "192.168.0.3",
"port": 5024,
"method": "socket",
"deviceName": "DeviceTest_API1",
"deviceType": "default",
"sendDataOnlyOnChange": false,
"pollPeriod": 2000,
"sendDataToThingsBoard": true,
"byteOrder": "BIG",
"wordOrder": "BIG",
"unitId": 1,
"values": {
"holding_registers": [
{
"timeseries": [
{
"tag": "setLPARAM",
"type": "16int",
"objectsCount": 1,
"address": 6151,
"value": 0
},
{
"tag": "setLTIME",
"type": "32uint",
"objectsCount": 2,
"address": 4432,
"value": 0
}
],
"rpc": [
{
"tag": "setLPARAM",
"type": "16int",
"functionCode": 6,
"objectsCount": 1,
"address": 6151,
"value": 0
},
{
"tag": "setLTIME",
"type": "32uint",
"functionCode": 16,
"objectsCount": 2,
"address": 4432,
"value": 0
}
]
}
]
}
},......

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

Error traceback (If it was raised):

ERROR tcp:187 Connection to (192.168.0.3, 5024) failed: [Errno 111] Connection refused
ERROR tcp:187 Connection to (192.168.0.3, 5025) failed: [Errno 111] Connection refused
ERROR tcp:187 Connection to (192.168.0.3, 5026) failed: [Errno 111] Connection refused

**Versions:**
 - OS: Ubuntu 24.04]
 - Thingsboard IoT Gateway version 3.5.1, 3.7.0 and newest
 - Python version [e.g. 3.9]

 **Additional context**
Add configuration files, logs or any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions