Modbus TCP timeout


I have a problem to get telegraf with modbus input get to work.

Modbus Input part of config:

  interval = "5s"
  name_override = "SDM120"
  name = "NOT USED"
  tagexclude = ["type", "name", "host"]
  timeout = "2s"

  controller = "tcp://"

  debug_connection = true
  configuration_type = "request"

# ---------------------------------------------- slave_id = 1 ----------------------------------------
  slave_id = 1
  byte_order = "ABCD"
  register = "input"
  fields = [
      { address = 0,    name = "Spannung",          type="FLOAT32" },
    sensor = "pv1"

When I start telegraf I get the following:

2022-11-23T19:13:44Z D! [agent] Connecting outputs
2022-11-23T19:13:44Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2022-11-23T19:13:44Z D! [agent] Successfully connected to outputs.influxdb_v2
2022-11-23T19:13:44Z D! [agent] Starting service inputs
2022-11-23T19:13:45Z D! [inputs.modbus] Reading slave 1 for tcp://
2022-11-23T19:13:45Z D! [inputs.modbus] trying to read input@0[2]...
2022-11-23T19:13:45Z D! [inputs.modbus] modbus: send 00 01 00 00 00 06 01 04 00 00 00 02
2022-11-23T19:13:47Z E! [inputs.modbus] Error in plugin: slave 1: read tcp> i/o timeout
2022-11-23T19:13:47Z D! [inputs.modbus] Reconnecting to tcp://
2022-11-23T19:13:50Z D! [inputs.modbus] Reading slave 1 for tcp://

If I test the connection on the same VM it will work:

It is a SDM120 Modbus Meter connected to a USR-DR302 Gateway.

I’ve tested a few configurations, but I could not find the error…

Greets NSC2001

I don’t see an obvious problem… The error however clearly indicates that the device does not respond within your timeout of 2 seconds. Not sure why this happens. Can you maybe try mbpoll as telegraf user just to rule out any permission issues!?

I have testet mbpoll and telegraf with the same user… with and without sudo…

Has anyone more ideas, how find the error or are there more debug possibilities?

The only thing I can think of is that this is a timing issue. You might try a nightly build and use the pause_after_connect option with say "100ms" or something…

Other than this I’m puzzled as your output clearly shows that the two programs send exactly the same byte sequence… Maybe tcpdump or similar can give a glue on timing etc…

Srebhan… Thanks for your help… but now I decided to go an other way. I go over Home Assistant which write into the Infllux DB.

1 Like

It would be interesting though if telegraf would work with your device/setup… :slight_smile:

1 Like