question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stabilize the operation if multicast traffic isn't available or lossy

See original GitHub issue
  1. Check if multicast messages was received in the past (“iam” discovery response / heartbeats) and log a warning.
  2. Recovery from “Invalid key” by retrieval of a new token (get_id_list)
  3. If every executed command needs a “token recovery” report a degraded performance because of the lack of multicast traffic.
  4. Implement an indicator if a command execution was successful (without invalid key response) to be sure a valid encryption key is used.

cp. https://community.home-assistant.io/t/pyxiaomigateway-problem-error-invalid-key/28168 https://community.home-assistant.io/t/xiaomi-gateway-integration-help-needed/28563/10 https://community.home-assistant.io/t/new-xiaomi-gateway-firmware-xiaomi-aqara-component/27637/30 https://community.home-assistant.io/t/xiaomi-gateway-not-discovered/25030/158 https://community.home-assistant.io/t/xiaomi-sensors-not-working-after-0-57-update-solved/31693/6 https://community.home-assistant.io/t/xiaomi-gateway-is-recognized-but-does-not-take-any-commands-or-brings-data-help-needed/28725

This is my explanation of the “invalid key” error:

Some responses (get_id_list (direct message), heartbeat (multicast)) of the gateway contains a “token” which is valid for a short period of time. The combination of the token plus the encryption key of the android app is used to calculate the “key” value of a “write” command:

{"cmd": "write", "sid": "34ce00909ed1", "data": {"rgb": 3036676095, "key": "5059aeccf37f66b5cfec0cdfaab76e29"}}

I don’t know the behavior of the gateway exactly but if you miss one (or multiple) of the temporary tokens a old/invalid token is used and the misleading “Invalid key” error pops up although your encryption key (android key) is fine.

We will implement a safeguard for the “Invalid key” error so a new token will be requested and a retry of the failed command wil be sent. Do not forget: The cause of the issue is packet loss. 😦

cp. https://github.com/Danielhiversen/PyXiaomiGateway/issues/21

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
PaulAnnekovcommented, Nov 14, 2018

Is the resolution to this going to mean no reliance on multicast?

No, it’s just fixing some minor issues with communication between client and hub.

There’s a history of multicast packets not functioning in Home Assistant that means lots of users with these gateways end up with timeouts after 2.5 hours.

That’s because their network is misconfigured. Aqara hub doesn’t provide another pushing communication method, except multicasting.

1reaction
syssicommented, Nov 28, 2017

I will use your code as basis and try to provide some iptable rules for testing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Multicast Traffic Issues in Same VLAN on Catalyst Switches
This document describes how to fix a multicast application failure when it is deployed in the same VLAN between Catalyst switches.
Read more >
BMRF: Bidirectional Multicast RPL Forwarding - ScienceDirect
In this paper we present Bidirectional Multicast RPL Forwarding (BMRF), a new multicast protocol that combines the best features of the Routing Protocol...
Read more >
Design and Implementation of a Central-Controllable ... - NCBI
IP multicast routing protocol does not record the topology (In ... We design the operation flow of CCSM which includes multicast membership ...
Read more >
Lightweight Application Level Multicast Tunneling using ...
the sender joins the multicast group and the network routing protocols makes that tra c available to the new receiver. When the receiver...
Read more >
Using Multicast FEC to Solve the Midnight Madness Problem
Not surprisingly, nearby University of Washington found that it was nearly impossible to get any traffic through the Internet due to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found