Skip to content

Do not reconnect if SunSpecModbusClientDevice.scan connect argument set #114

Description

@mossblaser

At the moment calling SunSpecModbusClientDevice.scan with connect=True (the default) will cause any existing TCP connections to be closed (with a new connection being opened and then closed within the method call). Because this leaves the device in a disconnected state, each subsequent operation also reverts to the "open a temporary connection for the duration of this command" mode too.

It would be ideal if SunSpecModbusClientDevice.scan were to use (and not close) an existing connection when the connect=True argument is passed.

Aside: Why do I care so much?

Accidentally reverting to a connection-per-command mode has a number of disadvantages:

  • It adds extra network-round-trips of latency to each operation
  • It adds extra load on the remote device which may be relatively resource constrained (this is especially true when TLS is used)
  • Using a long-running TCP connection allows you to detect remote device restarts during which the device map may have changed (e.g. after a firmware update). If a single TCP connection is used, the connection error after the connection is closed provides an indication that a new scan is might be needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions