小编vin*_*rnk的帖子

如何使用Paho MQTT javascript客户端连接IBM Watson IOT?

我正在尝试使用Paho MQTT Javascript客户端连接IBM Watson IoT平台,如下面的示例代码中所述.

 
 var client = new Messaging.Client("myOqgId.messaging.internetofthings.ibmcloud.com", 8883, "myclientid_" + parseInt(Math.random() * 100, 10));

 //Gets  called if the websocket/mqtt connection gets disconnected for any reason
 client.onConnectionLost = function (responseObject) {
     //Depending on your scenario you could implement a reconnect logic here
     alert("connection lost: " + responseObject.errorMessage);
 };

 //Gets called whenever you receive a message for your subscriptions
 client.onMessageArrived = function (message) {
     //Do something with the push message you received
     $('#messages').append('<span>Topic: ' + message.destinationName + '  | …
Run Code Online (Sandbox Code Playgroud)

javascript mqtt iot watson-iot ibm-cloud

5
推荐指数
1
解决办法
914
查看次数

标签 统计

ibm-cloud ×1

iot ×1

javascript ×1

mqtt ×1

watson-iot ×1