Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Automatic reconnect and offline buffering implemented for JavaScript Client

Hi all,
 
I have completed the development and manual testing of automatic reconnect and offline buffering for _javascript_ client.  You can see the summary of changes on github under this pull request
https://github.com/eclipse/paho.mqtt._javascript_/pull/72
 
The code is available here: https://github.com/miketran78727/paho.mqtt._javascript_
    (src/mqttws31.js)
 
To enable offline buffering, set  disconnectedPublishing = true.  Default offline buffer size is 5000, it can be set via disconnectedBufferSize property.  Here is an example:
 
      var client = new Paho.MQTT.Client(server, port, clientId);
        client._onConnected_ = onConnected;
        client._onConnectionLost_ = onConnectionLost;
        client._onMessageArrived_ = onMessageArrived;
        client._onMessageDelivered_ = onMessageDelivered;
        client.disconnectedPublishing = true;
        client.disconnectedBufferSize = 100;
 
To enable automatic reconnect, set reconnect option to true, e.g.:
 
       client.connect(
                {cleanSession : false,
                    onSuccess : onConnectSuccess,
                    onFailure : onFailedConnect,
                    keepAliveInterval : 10,
                    reconnect : true});
 
I have manually tested the code and I have not found any regression. I would appreciate additional testing and feedback.
 
--
Regards,
Mike Tran
 


Back to the top