Skip to content

v1.1.x (tmodbus) causes "Async TCP connection closed by remote host" on USR-N540 gateways #683

Description

@HAPV2

Description: Since upgrading to v1.1.1 (the switch to tmodbus), my USR-N540 gateway is actively dropping the TCP connections after a few minutes of polling. Rolling back to the older pymodbus version immediately restores 100% stability.

Hardware Setup:

3x Sunsynk Inverters connected to a single USR-N540 gateway.
Polling over Modbus TCP.
Troubleshooting Steps Taken: In an attempt to stop the TCP drops, we aggressively throttled the new driver to mimic the old driver's rhythm:

Set READ_MESSAGE_SPACING: 0.25 (and tested 1.0)
Set READ_SENSORS_BATCH_SIZE: 10
Set READ_EVERY: 15 (to ensure the spaced-out loop had plenty of time to finish and wasn't overlapping).
Despite the loop running perfectly within the 15-second schedule without overlapping, the USR-N540 actively kills the TCP connection after ~2.5 minutes:

text
[13:11:11] INFO Async TCP connection closed: 10.10.55.241:34
[13:11:11] INFO Async TCP connection closed by remote host.
[13:11:11] INFO Modbus TCP protocol connection established.
[13:11:11] INFO Async TCP connection established: 10.10.55.241:34
[13:11:14] ERROR ExceptionGroup: poll_need_to_read: Exception: OSError reading 3 registers from 109: timeout reading register 109

Conclusion: It seems the new tmodbus async socket implementation is handling TCP connections, framing, or keep-alives in a way that causes the USR-N540 firmware to panic and send a TCP RST/FIN. The old pymodbus driver handles this perfectly. For now, I have rolled back, but wanted to flag this hardware compatibility issue with the new custom engine!

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions