paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

Socket closed when subscribe 3000 topics

Open flynn-shu opened this issue 7 years ago • 1 comments
trafficstars

AMQJS0008I Socket closed

    function onConnect() {
        // Once a connection has been made, make a subscription and send a message.
        console.log("onConnect");
        // client.subscribe("World");
		//about 3000 topics
        for (var i = 0; i < topics.length; i++) {
            var topic = topics[i];
            for (var key in topic) {
                client.subscribe(key);
				//console.log("subscribe:"+key); when add this line will be ok. It seems to be blocking  
 current thread
            }
        }

    }

    // called when the client loses its connection
    function onConnectionLost(responseObject) {
        if (responseObject.errorCode !== 0) {
            console.log("onConnectionLost:" + JSON.stringify(responseObject));
        }else{
			console.log("onConnectionLost:" + 0 );
		}
    }

How to subscribe to multiple topics using one request? If have any idea how to solve this issue, please help me!

flynn-shu avatar Apr 25 '18 08:04 flynn-shu

In the version of the client currently in the develop branch, you can now subscribe to multiple topics in an array: client.subscribe(["tennis", "football", "rugby"]);

This will be available in the release version sometime in late June.

jpwsutton avatar May 08 '18 10:05 jpwsutton