I am using MQTT node.js mosca broker. I run it with this command;
mosca -v --http-port 3000 --http-bundle --http-static ./ | bunyan
I have a browser mqtt client. Code looks like this;
var mqtt_client = mqtt.connect('ws://127.0.0.1:3000');
mqtt_client.subscribe('hello/world');
mqtt_client.on('connect', function () {
console.log("MQTT connected");
});
mqtt_client.on("message", function(topic, payload) {
console.log([topic, payload].join(": "));
//mqtt client connection not closed as line below is commented
//mqtt_client.end();
});
Suppose I have many many similar browser clients each subscribing to a different mqtt topic. The user runs the webpage that calls the code, then close the tab. There is no code that explicitly closes the connection or close down the topic. Will the MQTT broker die from RAM overload?
When the tab is closed the websocket connection will also get closed so the broker should clean up the session, also if no messages or pings are received inside the keepalive period then the connection will also be cleaned up.
Topics can not be closed, there is no concept of ownership or open/closed, they are just identifiers for message routing.
If you are using QOS greater than 0 and persistent sessions, then it is possible for messages to accumulate while waiting for a specific client to reconnect, but a well written broker should store these on disk not in memory.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments