Problem with Remote Domoticz

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
Kedi
Posts: 622
Joined: Monday 20 March 2023 14:41
Target OS: Linux
Domoticz version: latest
Location: Somewhere in NL
Contact:

Problem with Remote Domoticz

Post by Kedi »

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.
I added some info about the data in the Source and compiled it again. No I receive this data.

Code: Select all

2026-04-06 12:36:27.803  Error: RemoteDomoticz: Invalid data received: {"BatteryLevel":100,"Color":"","
2026-04-06 12:36:27.803  Error: RemoteDomoticz: Invalid data received: ʘ�gSӫ՚켥ҒΪœp	дמȎʨ{
2026-04-06 12:36:27.805  Error: RemoteDomoticz: Invalid data received: zT\Ϻ�ڲ˴㡢۹ѾgȟAuK�JFݷI熢V[ɣFЯӟͱB˯ü텖勮˭x�zWkǥ?fT򡦢19�	ӂֶ>10iQS�Qʄ9:ڷVӞL䲡К`u�ݱ3(ӧb𣙓�
Anybody any idea where to look for or how logging could be enhanced or what is going on?
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Problem with Remote Domoticz

Post by gizmocuz »

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
Quality outlives Quantity!
Kedi
Posts: 622
Joined: Monday 20 March 2023 14:41
Target OS: Linux
Domoticz version: latest
Location: Somewhere in NL
Contact:

Re: Problem with Remote Domoticz

Post by Kedi »

Tnx, for the response and the solution.
Unfortunately the remote cannot be directly updated, do that perhaps in a few days.
Sometimes the first message is a little longer, like
RemoteDomoticz: Invalid data received: {"BatteryLevel":100,"Color":"","DeviceID":"42244","LastLevel":0,"LastUpdate":"2026-04-08 14:06:24","Name":"Badkamer.","Options":"","OrgDeviceRowID":146,"OrgHardwareID":7,"Signa

B.t.w. the DeviceID 42244 does not exists on both sides???
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Problem with Remote Domoticz

Post by gizmocuz »

If you made the patch in DomoticzTCP::OnData, after it tries to parse the JSON, It means the decryption did not went correct.

I think it is because of a truncation issue.

I made some more changes that should also catch this issue in beta 17676 (using it myself with 4 instances)
Quality outlives Quantity!
Kedi
Posts: 622
Joined: Monday 20 March 2023 14:41
Target OS: Linux
Domoticz version: latest
Location: Somewhere in NL
Contact:

Re: Problem with Remote Domoticz

Post by Kedi »

It took some time, because I had to go on a holliday for 2 months.
I upgraded both master and remote to build 18063 and everything is working now as it should.
Tnx. for the fix.
Logic will get you from A to B. Imagination will take you everywhere.
Post Reply