Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var robuino_operador = "";
- var robuino_local = "jarduino_2c72";
- var host = 'broker.mqttdashboard.com'; // hostname or IP address
- var path = "/ws";
- var port = 8000;
- function MQTTconnect() {
- if (mqttConnected) {
- mqttConnected = false;
- console.info("already connected !!");
- //~ mqtt.disconnect();
- return;
- }
- if (typeof path == "undefined") {
- path = '/ws';
- }
- mqtt = new Paho.MQTT.Client(
- host,
- port,
- path,
- robuino_local + parseInt(Math.random() * 100, 10)
- );
- var options = {
- timeout: 3,
- useSSL: useTLS,
- cleanSession: cleansession,
- onSuccess: onConnect,
- onFailure: function (message) {
- $('#status').val("Connection failed: " + message.errorMessage + "Retrying");
- setTimeout(MQTTconnect, reconnectTimeout);
- }
- };
- mqtt.onConnectionLost = onConnectionLost;
- mqtt.onMessageArrived = onMessageArrived;
- if (username != null) {
- options.userName = username;
- options.password = password;
- }
- var logx = "Host="+ host + ", port=" + port + ", path=" + path + " TLS = " + useTLS + " username=" + username + " password=" + password;
- console.log(logx);
- mqtt.connect(options);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement