This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MQTTSN Example: Client unable to reconnect to Broker after timeout

Hello,

I am currently using mqttsn publisher exams with keep allive time of 30 seconds, so according to MQTT standard if period of inactivity will be 45 second and the client is unable to recieve ping response or broker doesn't recieve ping request from client in fixed time it will break the connection.

I would like to know how could I reconnect client to the broker once the broker timesout the client connection. Currently I am checking the state of client using isConnected api but it indeed take 3-4 minutes to restablish a connection. 

I would like to re-establish a connection as soon as the mqtt-sn client get's time out. I can't wait for 2-3 minutes to connect to broker. Also currently I have to wait for the next publish to check whether my client is connected to broker or not.

For Example: if I take a python MQTT client with keep alive time of 60 second and turn off and turn on the mosquito broker , the python client immediately connects within few seconds. I want some solution like that for mqtt-sn client. 

Please provide some tried and tested code or help for the same.  

Parents
  • Hi Brian

    I will have to fix a bug with my install of the MQTT-SN router.

    I think I will be able to fix this at the start of next week. Sorry for this delay.

    Regards,
    Sigurd Hellesvik

  • Hi

    When I build and run the MQTT-SN sleepy publisher, I can not see the lag you are mentioning.

    It could be a problem with the MQTT-SN gateway.
    I used the https://github.com/osaether/otbr-mqtt-sn/, maybe you could try this?

    To set up this, install and setup docker. Then go to the releases in the mentioned github and download the otbr-mqtt-sn-1.2. This is a docker image.
    To unzip and load this, use:

    gzip -d otbr-mqtt-sn-1.2.tar.gz
    docker load < otbr-mqtt-sn-1.2.tar

    Then you can run the "docker run" command from the README to start the border router.

    Are you able to try this?

    Regards,
    Sigurd Hellesvik

  • Hello Sigurd,

    I am currently using Nordic Border Router image as suggested by Jonathan *** from Openthread Google Group. 

    And also that image is the latest one, so I don't think that could be the issue or no one ever checked with that image ? 

    According to my understanding the lag is because I have kept Keep Alive time of 60 sec, so after 90 sec only my MQTT client will be able to know that it has got disconnected from the broker. So can you please check with Nordic image itself.

    I would like reiterate I am able to reconnect to gateway but after that 90 seconds. In my publish function, I have condition to check whether client is connected or disconnected, if connected it will send data, if not connected it will re-initiate a connection with gateway. But for this to happen it has to wait 1.5 times the keep alive time period as per MQTT standard.  

    But how a normal MQTT client in my PC is able to connect to mosquitto broker after restart of broker I don't get the same result with my thread mqtt-sn publish client. 

    Thanks. 

Reply
  • Hello Sigurd,

    I am currently using Nordic Border Router image as suggested by Jonathan *** from Openthread Google Group. 

    And also that image is the latest one, so I don't think that could be the issue or no one ever checked with that image ? 

    According to my understanding the lag is because I have kept Keep Alive time of 60 sec, so after 90 sec only my MQTT client will be able to know that it has got disconnected from the broker. So can you please check with Nordic image itself.

    I would like reiterate I am able to reconnect to gateway but after that 90 seconds. In my publish function, I have condition to check whether client is connected or disconnected, if connected it will send data, if not connected it will re-initiate a connection with gateway. But for this to happen it has to wait 1.5 times the keep alive time period as per MQTT standard.  

    But how a normal MQTT client in my PC is able to connect to mosquitto broker after restart of broker I don't get the same result with my thread mqtt-sn publish client. 

    Thanks. 

Children
No Data
Related