in content/lib/paho-mqtt.js [1031:1061]
ClientImpl.prototype._doConnect = function (wsurl) {
// When the socket is open, this client will send the CONNECT WireMessage using the saved parameters.
if (this.connectOptions.useSSL) {
var uriParts = wsurl.split(":");
uriParts[0] = "wss";
wsurl = uriParts.join(":");
}
this._wsuri = wsurl;
this.connected = false;
if (this.connectOptions.mqttVersion < 4) {
this.socket = new WebSocket(wsurl, ["mqttv3.1"]);
} else {
this.socket = new WebSocket(wsurl, ["mqtt"]);
}
this.socket.binaryType = 'arraybuffer';
this.socket.onopen = scope(this._on_socket_open, this);
this.socket.onmessage = scope(this._on_socket_message, this);
this.socket.onerror = scope(this._on_socket_error, this);
this.socket.onclose = scope(this._on_socket_close, this);
this.sendPinger = new Pinger(this, window, this.connectOptions.keepAliveInterval);
this.receivePinger = new Pinger(this, window, this.connectOptions.keepAliveInterval);
if (this._connectTimeout) {
this._connectTimeout.cancel();
this._connectTimeout = null;
}
this._connectTimeout = new Timeout(this, window, this.connectOptions.timeout, this._disconnected, [ERROR.CONNECT_TIMEOUT.code, format(ERROR.CONNECT_TIMEOUT)]);
};