23
Views
0
Comments
[MQTT Mobile Client] Keepalive not used?
Question
mqtt-mobile-client
Mobile icon
Forge asset by Barduino
Application Type
Mobile
Service Studio Version
11.53.24 (Build 61544)
Platform Version
11.14.1.34396

It appears that the MQTT keepalive function is not used, or if it is used, has no affordance (Event) back to the main application that the keepalive has failed and the client has disconnected from the MQTT server.


Ideally, there would be an additional event output from the mqttSubscribe block such as 'Disconnected' that way when the client is no longer connected to the server it does not just sit there idle and disconnected, but the application is notified and appropriate steps to reconnect can be taken, or user notified.


I've looked at the module and it appears that the only affordance for any sort of disconnect might be in the  'OnComponentWillUnmount' client action.

I am unsure as to the function of the 'unmounting' console log check inside the JS of this action, or if it would even be appropriate to add a disconnected event to pass up to the application using this module from this point.


If possible could we get a 'disconnected' client event or some other functionality to be notified when a disconnect has happened or at least a way to poll the client for a status?


You can recreate this disconnect by connecting to the client normally, putting your computer to sleep or hibernate, and then start your computer back up. It also seems to happen intermittently to clients that have the page open for very long periods of time without closing, but we cannot find an exact time limit as it seems to range from 20-30 hours.


I caused the error to happen on the included demo by clicking off of the tab for several minutes and then coming back. This message appeared in the console log:

mqttClient Connection Lost: AMQJS0008I Socket closed.


So the client knows when it has been disconnected but we get no affordance for that situation in the application we are using the webblock on. How could we get this data to the application to cause a refresh or reconnect? A google of pulling console logs via javascript shows its not directly possible and what little information is available on workarounds does not seem simple enough to implement ourselves.


Thanks!
Braxton Bragg

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.