-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoAP Pair-Verify timeout #78
Comments
It's a good question. It's been a while since i've looked at the startup path. From what I remember (and a very quick look):
So on the "happy" path I wouldn't expect any delay during HA's startup - the connect should happen in the background. The case where there is no characteristic cache should be quite rare, in which case I think is reasonable. |
The The implementation is messy, and thats largely driven by a poorly defined lifetime/ownership model. It was also added before the zeroconf component matured to the level its at today. You could probably get away with just letting zeroconf announce when it came back online. Also right now polling is frequent enough that just letting HA wake the connection back up is fine. Though if we reduce polling for the sake of battery devices that might not be the case. |
I added a traceback print & here's what I'm seeing... it looks like subscribe is triggering a connect. The web interface has that message at the bottom "Home Assistant is starting, not everything will be available until it is finished."
It tries to connect 7 (!!! I thought it was 3) times before giving up & then the web interface finishes loading. If I change the pair-verify timeout to 40s, it takes 7 * 40s for the banner thing to disappear. I haven't figured out why yet.
|
Eep. My memory and late night glances were not enough. So it is triggered by
I think that will stop the I/O if you have an up to date cache. I also wonder about not having subscribe do I/O unless it is already connected. We could look to reduce the number of subscriptions. E.g. If the entities asking for a subscription didn't trigger right away. We could do a single batch call at the end of |
Argh now, that will mean the backend doesn't know about the subscriptions at all though. |
So it already is just making one call to subscribe after add_entities, so I don't know what is happening at all 😆 So here is what I was planning for IP:
We already do bits of this in |
I think BLE will always be connect on demand, as those things really like to be disconnected. Theres like a 10-20s window where you can reuse the existing session. Subscribe there will be subscribe if connected, otherwise remember for when you connect. |
I imagine CoAP is somewhat similar to the existing IP backend, but as there is no "connection" in UDP its mostly s/connection/session/. The "reconnect loop" could be something that does one of those ping packets you talked about and re-pair-verifies if the ping fails? |
Found the source of the problem. I added the connection locks to the CoAP path because I was seeing overlapping connection attempts... the culprit is |
What do you think about the current CoAP pair-verify timeout of 8s? During startup, HA will try to connect 3x causing a 24s delay to HA startup if any HAP/CoAP device is unreachable. I don't have any battery-powered devices but I feel like 4s should be enough for just about anything to complete pair-verify.
The text was updated successfully, but these errors were encountered: