-
Notifications
You must be signed in to change notification settings - Fork 0
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
Device disconnects from AWS (and WiFi?) after period of inactivity #8
Comments
Worked the first night. Keep testing |
Ok, it's not tied to inactivity. It happened this morning within minutes of me using the devices. |
Dunno wtf happened here...I just uploaded some code, pushed the button and things were cool then blamo. Possible red-herring....ignore but keep this note
|
Possibly related to battery? Both devices use RAVPower 6700. Both devices typically disconnect at the same time (which is interesting because they and their batteries are independent entities). Interesting observation is that one device which has been connected to my computer via USB did not disconnect while the other, which is battery-powered, did. (Update - this may be because the battery ran out!) Tests to run:
|
7:00PM Both devices have disconnected and reconnected. Different batteries. 6 mins apart (this is important). Neither are in the pillow On 3/18/19 at 4:25, one device disconnected and reconnected (feather 2). This device is plugged into the PKCELL battery, is in it's enclosure but not in a pillow. The other device is plugged into the RAVPower and didn't lose connection. |
As per Issue #17, I coded a button long-press event to restart the ESP chip. Today, the device disconnected and I pressed the button. It did not reset the chip, but a few random pixels on the strip lit up as if in calling state. I can replicate the behavior by pressing it again. However, it doesn't restart. So what does this mean? It means the button press registers but the logic doesn't execute correctly... |
feather_esp32_2 is plugged into a 5v power switch (not a battery) and went for nearly 24 hours. But overnight it disconnected (and re-connected) several times. However my other device (running FreeRTOS) didn't disconnect. I'm thinking more and more that this has to do with the MQTT client library (in the notes it says to put a delay(10) after client.loop() ) |
I'm now reading about the MQTT Keep Alive concept. Notably, it says, "If the client does not send a messages during the keep-alive period, it must send a PINGREQ packet to the broker to confirm that it is available and to make sure that the broker is also still available. The broker must disconnect a client that does not send a a message or a PINGREQ packet in one and a half times the keep alive interval. Likewise, the client is expected to close the connection if it does not receive a response from the broker in a reasonable amount of time." Note that the library's keep alive is 10 seconds by default (configurable) and the longest allowed by the protocol is 18h 12m 15s (go figure). "Usually, a disconnected client tries to reconnect. Sometimes, the broker still has an half-open connection for the client. In MQTT, if the broker detects a half-open connection, it performs a ‘client take-over’. The broker closes the previous connection to the same client (determined by the client identifier), and establishes a new connection with the client. This behavior ensures that the half-open connection does not stop the disconnected client from re-establishing a connection." Maybe I'm dealing with some cases of half-open connections and AWS doesn't detect it properly... |
…ult used in AWS's sdk. See Issue #8
AWS's embedded c sdk uses a default keep alive of 1200 seconds (!). I wonder why there's is so different from the 10 second default in arduino mqtt.... Anyway, I changed the setting in my code and uploaded to feather_esp32_4 Note that feather_esp32_2 is still running using the default setting |
Ok, I've seen feather_esp32_2 disconnect a couple of times but not feather_esp32_4. |
Update - The device still disconnects and causes a UX error. It just messes up less often. I wish the freaking library could figure out it's not connected and fix itself...I'm sure there's a way but the standard check of client.connect() isn't working. Oh well, I'll go back to resetting the chip every hour I guess....or add a heartbeat |
Closing issue. While this isn't fully understood, periodic restarts seem to help |
Not clear if it dropped WiFi or AWS. Rebooting fixed it
Error code
/** Returned when the Network is disconnected and reconnect is either disabled or physical layer is disconnected */
NETWORK_DISCONNECTED_ERROR = -13,
The text was updated successfully, but these errors were encountered: