-
Notifications
You must be signed in to change notification settings - Fork 280
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
'No Response' after reboot/ssid_off WiFi router #139
Comments
I, too, have recently experienced this problem. Originally I thought it was a problem with my code, but it seems like the problem may be elsewhere. I've been thinking about writing a public server_free function, for the following scenarios;
I did want to mention that I have Arduino statsd instrumented as well, the statsd stuff works on reconnect. So the core loop is operating as intended. Just the HomeKit server stuff doesn't respond after a reconnect. |
The problem with using the "ESP.restart()" would be that the device would lose the active status. e.g.: a light bulb via relay would turn off and the user would need to activate it again. Yesterday I tested the option to unload the entire wifi stack and reconnect, but it didn't work either. I believe it's a problem regarding the session/socket break instructions. I'm studying all the code to try to find a solution, but I'm not an advanced programmer. If anyone has any ideas, help us. |
I found a workaround to solve the reconnection issue. Inside the source code "arduino_homekit_server.cpp", in the function "void arduino_homekit_setup", I created a check if the mDNS service is active. Otherwise, it calls accessory pairing and as a result also starts the mDNS service. Works well for now. I'm checking that there won't be any side effects. void arduino_homekit_setup(homekit_server_config_t config) {
|
I'm also trying to find a workaround and I would like to try your solution. I'm a bit noob and confused, why did you add this snippet of code
into "void arduino_homekit_setup" as opposed to let's say "void arduino_homekit_loop"? isn't the setup only run once when the esp restarts? Another confusion that I have is that "void arduino_homekit_setup" already runs "homekit_server_init(config)" (at least in the 8266 library) regardless of mDNS status and the issue is still there. Thank you for your time and answers. |
+1 has this problem. I have tested 2 WiFi routers with simplest code. |
I am linking another relevant issue |
huh, do you have a working theory as to why this works? Edit: I made two identical devices, one with this change and one without and I'm glad to say that the one with the change did not disconnect a single time over several weeks, whereas the one without the change disconnected multiple times. |
iOS 15.1, this problem. Did not help.. |
Is this the best solution so far? |
I have been changed the code to //MDNS.close(), but the error is the same. Then I put the reboot of ESP to monitor at thingspeak. |
Have a try of my version https://github.com/ruleechen/home-switch/blob/main/extras/arduino_homekit_server.cpp I have some little customizations. Probably helps. Good luck. |
Hi! @ruleechen I try replace arduino_homekit_server.cpp but I’m having some error.
|
@mateusmsantin |
@ruleechen |
@ruleechen Thanks! it's working, but unable restore previous relay state after power off&on |
@Sanjayc1806 |
@ruleechen yeah, we can do that using EEPROM and it's working fine while using webserver localhost buttons... thanks for your version of code......it's working great now |
@Sanjayc1806 Welcome. Mine is up for over 10 days now. |
Hi @ruleechen, Can you provide me the modified code for ESP32? Thank you in advance!! |
I facing the same issue. After I found this page. I review homekit_mdns_init() in ardunio_homekit_server.cpp and MDNSResponder::close() in LEAmDNS.cpp . The theory maybe:
|
I think you might be on to something here. Looks like if WiFi reconnects, we need to re-advertise those services, and we’re simply not. Going to play with just removing the condition, and clearing/adding the service every time mdns_init is called. Further evidence:
But if, like you point out, the services are actually gone, then they won’t be re-advertised, so HomeKit isn’t aware they exist. My guess is that if we reboot soon enough (due to some watchdog condition, or memory leak), we just reinit, but if we don’t reboot for sometime, HomeKit assumes we’re gone. |
Okay, so digging deeper into the actual mDNS announcements, I noticed that the device IDs are changing which explains everything. The attempts thus far have been to optimize the mDNS code itself, but this doesn’t solve any problems if the accessory ID changes (which appears to happen randomly) The problem I’ve been having isn’t that the device gets disconnected, it’s that when the device comes back online, it’s failing to find its ID, and generating a new random one. To the network, it’s a brand new device. It looks like my problem is that something is colliding with the address space in the EEPROM that this library is using for the ID. Hope this helps someone else! |
Okay, so it doesn’t look like I was overlapping. Seems to be an error handling issue in the “compact_data” function. Looks like any time there’s a topology change, HomeKit notifies the device to update its pairing info. This happens often now with the new HomeKit topology changes… the bad news is, if the device reboots, or fails to read from the flash for any reason (preemption, watchdog, etc…) it blanks out the “magic” bytes completely invalidating the config/pairing data and doesn’t fix it causing the boot process to think the device ID is invalid, and generate a new one. HomeKit looks for the old device ID, and can’t find it. The device then advertises itself as a brand new device. Working on a fix. WIll post as a PR when done. |
- Might fix Mixiaoxiao#103, Mixiaoxiao#139, Mixiaoxiao#147, Mixiaoxiao#184, Mixiaoxiao#198 - Also adds changes by @ruleechen - Also adds changes by @thiti-y
- Might fix Mixiaoxiao#103, Mixiaoxiao#139, Mixiaoxiao#147, Mixiaoxiao#184, Mixiaoxiao#198 - Also adds changes by @ruleechen - Also adds changes by @thiti-y
Everything goes fine until the network's wifi router goes down/restart. ESP serial reports sucessful reconnection, but devices are no longer able to communicate with the Home app ("No Response" red message). To working again, only restarting esp. Anyone else experiencing this problem?
Below, the result displayed in the serial:
The text was updated successfully, but these errors were encountered: