Skip to content

TCP RTU Bridge: race condition with multiple clients #399

@zivillian

Description

@zivillian

Describe the bug
I'm connecting with two polling clients (evcc every 10s & nodered every 30s) to a TCP/RTU Bridge (heidelberg-1p3p). Every now and then I get the following error message in evcc:

heartbeat: modbus: response data size '28' does not match request quantity '1'

The response data size (28) matches the size of the requests I'm issuing from nodered, so it looks like one client receives a response from a different client.

If I'm correct the library is using millis() to assign a unique identifier to the bridge requests. After a quick search, it looks like millis() only has a resolution of 10ms, but even with 1ms resolution it may hit a collission.

Expected behavior
Clients only receive their own response.

To Reproduce
I was able to easily reproduce this with a small c# program running two clients with different request sizes in a loop (~15% collisions).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions