Skip to content
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

Ping Response Resolver in mqttsn client #243

Open
nikhil1983 opened this issue Sep 5, 2021 · 1 comment
Open

Ping Response Resolver in mqttsn client #243

nikhil1983 opened this issue Sep 5, 2021 · 1 comment

Comments

@nikhil1983
Copy link

Hello,

I am currently using MQTT-SN client to connect to MQTTSN gateway. I have my client connected with a keep alive time of 30 seconds.

So during no activity if my mqtt-sn client is unable to send ping request to gateway or doesn't recieve ping response from gateway, how could I find that ? How could I find my whether my client is still connected or not ? Because broker would close connection after 45 second if it doesn't recieve any response from my mqtt-sn client.

I require help in re-initiating a client connection process with gateway as soon as my client get's timedout due to inactivity.

Can anyone please tell me how could I start new connection after getting disconnected. Or which part of the code processes the ping response information.

@campescassiano
Copy link

You can send a PINGREQ to the Gateway, and if you have been disconnected, Gateway will not reply.

But, since it is UDP, you may want to retry sending the PINGREQ more N times, for example, and if after all retries it failed to receive the PINGRESP from Gateway, then you may conclude that your connection to the Gateway was lost somehow. This is a good idea just to make sure that it is not a packet routing problem or something like that.

Thus, you can restart your client-side by sending CONNECT, and start over the connection.

One more thing that would be better before sending the CONNECT, is to send DISCONNECT first, just to make sure (or at least as a best effort) try to tell the Gateway "if you still think I am connected to you, please I am DISCONNECTING". Thus, if for any reason the Gateway still thinks your client is connected, now it will know that your client disconnected, and then the Gateway will release all the resources and it will be ready to wait for any new connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants