horihiro / esp8266-google-home-notifier

MIT License
103 stars 23 forks source link

Many Google Devices and OOM Errors #41

Open wiltwong opened 2 years ago

wiltwong commented 2 years ago

If you have a large number of google devices on your network there are two issues:

  1. The mDNS query will fail because by default it will only wait 10 seconds for a response. Easily fixed, because there is already a timeout parameter to the device() function. For my network I had to increase it to 90 seconds.
  2. The mDNS response is large and is stored in RAM. With a moderatley large response, either the esp8266 will crash with an OOM exception, or it might work depending on when you get the TXT response you are looking for (i.e. we break out of the response processing loop sooner), or you will get a into a loop with a cryptic "Failed to Connect" error from BearSSL since it encounters an OOM exception.

For the second issue, since we really only call mDNS once and then save the IP and port results in memory, we can probably #define NO_GLOBAL_MDNS and use MDNSResponder locally in the device() function, once the function returns the local MDNS is destoyed and the RAM is reclaimed.

Thoughts?

horihiro commented 2 years ago

Because I don’t have any ESP8266/32 devices now, I will archive this repository. Fork this repo and fix them.