Kedi wrote: Monday 06 April 2026 18:48
I have a remote Domoticz, which sends 8 devices to the main Domoticz. It looks like all tose devices are received by the master in good order.
The last few weeks I get errors like "RemoteDomoticz: Invalid data received" with no extra info.
Thanks for reporting. I assume you made a patch in DomoticzTCP::OnData
Root Cause
TCP is a stream protocol — there is no guarantee that one async_read_some call delivers exactly one complete message. When devices update rapidly (the user has 8 devices), two problems occur:
- 1. Fragmentation: A large encrypted payload arrives in multiple TCP segments → OnData gets a partial ciphertext → AES decrypt fails
- 2. Coalescing: Multiple device updates sent back-to-back arrive as one blob → only the first message (if it decrypts at all) is processed
Neither the server (tcpserver/TCPServer.cpp → SendToClient) nor the client (hardware/DomoticzTCP.cpp → OnData) use any length prefix or reassembly buffer. The raw encrypted bytes are passed directly to AESDecryptData regardless of completeness.
I increased the server/client version number, and a length field. This should now be solved in the latest beta version (17667).
Do note that you need to upgrade both instances