-
Notifications
You must be signed in to change notification settings - Fork 1k
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
PINGRESP ignored in umqtt.simple.py #332
Comments
I'm going to have to upvote this... I feel like this should be the case as well. umqtt.robust doesn't fix this either. We need to know if the connection is still active or not. I found some code on https://github.com/AntonisKekempanos/SonoffMicropythonMQTT.git Where they return b'PINGRESP' this seems like an appropriate return code for the ping. |
I don't know much about mqtt however from a quick search it appears that clients (like this module) are supposed to send a PINGREQ to the broker regularly, to which the broker responds with PINGRESP. Changing wait_msg to return something different when this comes in would affect existing users of the library who haven't had to expect this message and know how to deal with it. Perhaps instead of returning something, The library could have a new attribute in the mqtt client class where a timestamp is updated every time one of these comes in, that way an application that cares about it can query that attribute to see how long it's been since the last server communication? |
+1 I love that idea! That would help with about half the code I'd be trying to write to check the time intervals between pings. So yes, love it! |
@andrewleech were you thinking of https://github.com/fizista/micropython-umqtt.simple2.git when you suggested having it be an attribute of the client? Because it seems like that's exactly what's been implemented. |
I've never seen that library myself, to be honest I haven't used mqtt at all. |
@michaeka79 Maybe you have any ideas to fix it? |
Not using it anymore... |
Spent some time trying to figure out why pings weren't working before finding this issue. Is there a rationale behind this? The docs even seem to imply that this should be handling the ping
That implies to me not that the ping is ignored, but that I've forked this and swapped the I'm happy to make either change, they are very straightforward, not sure though if this is actually a desired change. |
My understanding is that none of the current owners / maintainers of micropython-lib really use or know much about mqtt - hence this library hasn't seen any real work or expansion. As such I really don't know if there's anyone who could really answer your question about the correct way to handle this, or what should be done to fix it. |
I opened a pr with the solution I've been using locally. It's minimally invasive and non-breaking which is why I went with this approach although I'm not necessarily the most python oriented dev so it's possible this is an unusual approach in python. But I wanted to propose it since this issue has been open for some time and the current |
Hello,
In wait_msg, the PINGRESP message is ignored:
Shouldn't this return some information so that the calling code can determine if the server is indeed responding to pings?
The text was updated successfully, but these errors were encountered: