Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('using websockets, will connect to \'' + url + '\'...');
}
options.url = url;
} else if (protocol === 'wss-custom-auth') {
options.url = prepareWebSocketCustomAuthUrl(options);
if (options.debug === true) {
console.log('using websockets custom auth, will connect to \'' + options.url + '\'...');
}
// Treat the request as a standard websocket request from here onwards
protocol = 'wss';
}
return protocols[protocol](client, options);
}
var device = new mqtt.MqttClient(_wrapper, options);
//handle events from the mqtt client
//
// Timeout expiry function for the connection timer; once a connection
// is stable, reset the current reconnection time to the base value.
//
function _markConnectionStable() {
currentReconnectTimeMs = baseReconnectTimeMs;
device.options.reconnectPeriod = currentReconnectTimeMs;
//
// Mark this timeout as expired
//
connectionTimer = null;
connectionState = 'stable';
}
return new Promise((resolve, reject) => {
(path
? MQTT.MqttClient(() => net.createConnection(path), {
resubscribe: false
})
: MQTT.connect(...args)
)
.on('connect', function(connack) {
/**
* If `false`, this is a clean session
* @public
* @memberOf client
*/
this.sessionPresent = Boolean(connack.sessionPresent);
})
.once('error', reject)
.once('connect', function() {
resolve(toadpatch(this, opts));
});