B4J Question [SOLVED][BANano] Initializing BANanoMQTT with wss

Mashiane

Expert
Licensed User
Longtime User
Hi

I need a way to set the protocol for BANanoMQTT to be wss, does it default to that when one specifies that Secure parameter to True by default?

I just checked the debug code of my app to get some kind of indication.

B4X:
// [200] Sub MQTTConnect 
_B.mqttconnect=function() {
var _ops;
// [201]    Log( {50} ) 
console.log('■[BROWSERApp: 201]',"MQTT - ConnectAndReconnect...");
// [202]    MQTTWorking = True 
_B._mqttworking=true;
// [203]    MQTTTimer.Initialize( {51} , 5000) ' Timer checks every 5 seconds 
_B.__mqtttimer.eventname="mqtttimer";
_B.__mqtttimer.interval=5000;
_B.__mqtttimer.enabled=false;
_B.__mqtttimer.isinitialized=true;
// [204]    MQTTTimer.Enabled = True 
_B.__mqtttimer.enabled=true;
_B._mqtttimer=setInterval(_B.mqtttimer_tick, _B.__mqtttimer.interval);
// [207]    mqtt.Initialize( {54} , {55} , 443, {56} , True, {57} ) 
_B._mqtt =new Paho.MQTT.Client("123.456.789.100",443,"/mqtt/","xxx");
_B._mqtt.onConnectionLost=function() {_B.mqtt_disconnected();};
_B._mqtt.onMessageArrived=function(message) {_B.mqtt_messagearrived(message.destinationName, message.payloadBytes);};
var _mqtt_conn={onSuccess:function() {_B.mqtt_connected(true);}, onFailure: function() {_B.mqtt_connected(false);useSSL=true}};
// [208]    Dim ops As BANanoMQTTConnectOptions 
_ops={};
// [209]    ops.Initialize(MQTTUser, MQTTPwd) 
_ops.userName=_B._mqttuser;
_ops.password=_B._mqttpwd;
// [210]    ops.CleanSession = False 
_ops.cleanSession=false;
// [212]    mqtt.Connect2(ops) 
_B._mqtt_conn=_ops;
_B._mqtt_conn.useSSL=true;
_B._mqtt_conn.onSuccess=function() {_B.mqtt_connected(true);};
_B._mqtt_conn.onFailure=function() {_B.mqtt_connected(false);};
_B._mqtt.connect(_B._mqtt_conn);
// End Sub
};
 
Top