thingsboard-gateway icon indicating copy to clipboard operation
thingsboard-gateway copied to clipboard

[BUG] Socket is closed, connection is lost, for device ***

Open Ellean opened this issue 8 months ago • 1 comments

Describe the issue "Socket is closed, connection is lost, for device ***"

This problem occurred at first, and it disappeared after I changed the port from ttyUSB10 to /dev/ttyUSB10.

When I added a new gateway (B) with new connector (B1), the problem reappeared. When I remove the former connector (A1) from former gateway (A) and added a new connector (A2), the problem reappeared.

Additional Info:

  • Can read data with the software offered by vendor (on Windows).
  • Can read data with following command in CLI (on the host machine running gateway) modpoll -m rtu -a 1 -r 512 -c 1 -t 3 -b 9600 -d 8 -p none -s 1 /dev/ttyUSB10
  • Can NOT read data from both address 511&512

Configuration (Attach your configuration file)

{
  "master": {
    "slaves": [
      {
        "method": "rtu",
        "baudrate": 9600,
        "stopbits": 1,
        "bytesize": 8,
        "parity": "N",
        "strict": true,
        "unitId": 1,
        "deviceName": "***",
        "deviceType": "***",
        "timeout": 35,
        "byteOrder": "BIG",
        "wordOrder": "BIG",
        "retries": true,
        "retryOnEmpty": true,
        "retryOnInvalid": true,
        "pollPeriod": 5000,
        "connectAttemptTimeMs": 5000,
        "connectAttemptCount": 5,
        "waitAfterFailedAttemptsMs": 300000,
        "type": "serial",
        "attributes": [],
        "timeseries": [
          {
            "tag": "wet_temp",
            "type": "16int",
            "address": 512,
            "objectsCount": 1,
            "functionCode": 3,
            "divider": 10
          }
        ],
        "attributeUpdates": [],
        "rpc": [],
        "port": "/dev/ttyUSB10"
      }
    ]
  },
  "logLevel": "INFO",
  "name": "ModBus",
  "enableRemoteLogging": false,
  "id": "520f8975-5da3-4073-9537-f7c25185aa4f",
  "configVersion": "3.7.0"
}

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

Error traceback (If it was raised):

Versions (please complete the following information):

  • OS: Ubuntu 20.04
  • Thingsboard IoT Gateway version 3.7.0 (Docker Compose)
  • Python version No Python installed on host

Ellean avatar Mar 12 '25 19:03 Ellean

Work around:

I tried to add the following code in docker-compose.yml:

devices:
    - "/dev/ttyUSB10:/dev/ttyUSB10"

Problem solved, I forgot that I added in the former one after all.

Change type to [BUG]

But I think this is NOT the designed way to do this.

It can NOT be solved while CLI is NOT an option.

OR

If this is the recommend way, it should be mentioned in official document.

Ellean avatar Mar 12 '25 20:03 Ellean