-
Notifications
You must be signed in to change notification settings - Fork 51
"keepalive" pings do not keep the connection alive with esp32spi #68
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
Comments
Hi, thanks for filing an issue. I need some information in order to help replicate and fix this issue... Which broker are you connecting to? What KeepAlive time are you specifying?
Could you attach the REPL log when this happens so I can see which exception is thrown, and exactly where?
This is not correct and will be addressed in a subsequent PR by removing the |
Hi; I'm connecting to a local broker, no security. (Broker is mosquitto on a mac.) It connects fine, and as long as the matrixportal gets a message within the keepalive time (like if I post every so often with mosquitto_pub) it stays connected and works reliably. I've tried a few different KeepAlives; the exception is raised always KeepAlive seconds after the last message was received. Here's the exception:
|
Here's a minimal-ish example that you can also use to see the logging issue as well by changing from INFO to DEBUG.
|
Hi again; here's a modification that is working for me in case it's useful. https://github.com/dlizotte-uwo/Adafruit_CircuitPython_MiniMQTT |
@dlizotte-uwo Would you mind opening these changes as a new pull request on this library and tagging me? I'd like to have a discussion around them. I think raising within exact_recv like you're doing in (dlizotte-uwo@1c0f6c8) is a good idea and will fix the blocking issue. |
OK - I think I did the PR thing right but I've never done it before so let me know if anything is amiss. 😅 |
I'm able to replicate hanging on the adafruit io simpletest with esp32spi..
Seems to be hanging in the same place you've pointed out:
I'll try your PR next #69 |
Merged into |
If I connect to a broker, subscribe to a topic, and no messages arrive from the broker within
keep_alive
seconds, an exception is thrown and the object disconnects. Pings are not sent to the broker to keep the connection alive.This happens because
loop()
is actually blocking in the esp32spi implementation, and so doesn't get a chance to send/receive a ping to reset the object's timestamp.loop()
is blocking because_wait_for_msg()
is blocking, which is because_sock_exact_recv()
is blocking as currently implemented, I think just in the ESP32SPI implementation withoutsocketpool
. (Also note_sock_exact_recv()
is defined twice in the file, once around line 312 and again at 894.) It's a bit weird because the timeout sent toloop()
is applied toself._sock
but then_wait_for_msg
overwrites that (if it succeeds) with its own timeout. Either way the code in_sock_exact_recv
for ESP32SPI waits for keep_alive seconds and then throws an exception, which defeatsloop
's ability to ping and reset the timestamp. I don't know what the "right behaviour" should be in this whole setup.I am using a MatrixPortal with esp32spi.
The text was updated successfully, but these errors were encountered: