Comments (10)
If a crash + recovery happens quickly (before records expire) would we detect that connection might be broken?
from aiohomekit.
Maybe a is_advertising
property on the pairing
BLE -> -- we have a description -- effectively always true if we have ever seen the device
IP -> -- zeroconf record is present ---
COAP -> -- zeroconf record is present ---
from aiohomekit.
If a crash + recovery happens quickly (before records expire) would we detect that connection might be broken?
If it hard crashed the zeroconf record wouldn't get withdrawn (requires an announce with a TTL of 0) and we can't tell the difference between the accessory sending an unsolicited broadcast at startup and a normal response so we wouldn't know its crashed from zeroconf alone
from aiohomekit.
If it does drop and come back we will get a TCP RST though so we know we need to poll if the connections gets reset by peer
from aiohomekit.
I'm not sure we'll always get an RST.
If connection is established and idle and there's nothing like NAT or keep alives, and then there is a hard crash, the device will just vanish without sending one.
from aiohomekit.
When the device reconnects to the network aiohomekit's stale connection will keep trying to talk to the device, and when the device's TCP stack sees it trying to talk over a connection that isn't established its going to send back an RST because aiohomekit's connection isn't known.... at least if it implements TCP/IP correctly
from aiohomekit.
We would also want to poll again for any connection drop, the RST case is just the obvious case of the accessory rebooting
from aiohomekit.
If connection is established and idle and there's nothing like NAT or keep alives, and then there is a hard crash, the device will just vanish without sending one.
If its a hard crash and its not coming back it would wait for the zeroconf record to expire before it would poll, fail, and mark it unavailable.
from aiohomekit.
Its always going to be a trade off though.
The other option is to change the poll interval to be higher when the zeroconf record is present so we reduce the traffic at the cost of waiting a bit longer to be unavailable.
I tend to thing traffic reduction is more important than quick unavailability reporting given how frequently we get wifi and network related issues but not sold either way.
from aiohomekit.
I don't disagree getting rid of polling would be better.
We could back off the poll interval and see if anyone notices.
Something else to think about... The docs we have access to AND the open ADK mandates that s#
be 1. Yet most of my certified IP devices care to disagree:
Name: Hive Bridge (QYQ-313)
State Number (s#): 91
...
Name: Philips hue - 482544
State Number (s#): 183
...
Name: Elements F3C8
State Number (s#): 8
...
Name: eufy HomeBase2-0CEB
State Number (s#): 615
...
Name: Aqara-Hub-E1-91C7
State Number (s#): 915
The ones that seem to be at 1 are an Arlo baby camera and an Eve Extend.
I found some logs on the ADK issue tracker (issue 43) that suggest MFI devices might republish their zeroconf record when an event happens and no one is connected. The log strings don't exist in the open ADK though (I think someone might have raised a ticket in the wrong place - i.e. in a public tracker instead of a private tracker).
I also found this in the HTTP event code path of the esp HomeKit sdk:
/* If no controller was connected and no disconnected event was sent,
* reannaounce mDNS. That will increment state number as required
* by HAP Spec R15.
*/
if (!ctrl_connected && !hap_priv.disconnected_event_sent) {
hap_mdns_announce(false);
hap_priv.disconnected_event_sent = true;
}
Perhaps we should track the s# for changes? As if s# is only incremented (as suggested in above code) when no one is connected, it might mean we think we are connected but aren't?
from aiohomekit.
Related Issues (20)
- Process notifications as disconnected events if we cannot decrypt so we don't get out of sync
- Modify COAP and IP backends to send state right away like we did for BLE
- Raise a subclassed exception of ValueError when a service is missing so we can disconnect and let the retry reconnect to force BlueZ to re-resolve services
- Pair by QR code or NFC tap
- Replace most asyncio.wait_for with async_timeout or asyncio.timeout on 3.11
- Sleepy Thread devices HOT 8
- Avoid BlueZ mtu warning by setting `_mtu_size`
- Always subscribe to all available encrypted notifications
- Characteristics for Fibaro Wall Plug (Homekit version)
- Slow response and warn logs for Nuki HOT 5
- Don't fetch programmable switch events on reconnect without getting a GATT notify for them HOT 5
- There is a race where we can be waiting for the device to be detected at startup and we get it more than once because we don't clear it before its detected again
- Fetching friendly_name does a linear search
- Using aiohomekit standalone: transport not supported HOT 2
- Eve Degree: Various BLE errors HOT 1
- asyncio.exceptions.TimeoutError during zeroconf search needs to be re-raised as AccessoryNotFoundError
- Log says "pairing established" but any interaction throws "is no known alias" HOT 4
- `first` to get accessory_info at startup is unexpectedly expensive
- Connection refused HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohomekit.