cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1299
Views
0
Helpful
6
Replies

Strophe XMPP client error

pravin1
Level 1
Level 1

Hi Team,

We have developed custom finesse desktop using strophe rest API. It is working fine but after sometime it is sending below error in browser console logs.

 

function _onConnect(status) {
console.log("_onConnect() - XMPP client onCONNECT fired");
// THESE STATUS CODES ARE SELF EXPLANATORY, for more info check the official documentation of Strophe Library.
if (status === Strophe.Status.ERROR) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.ERROR);
} else if (status === Strophe.Status.AUTHFAIL) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.AUTHFAIL);
} else if (status === Strophe.Status.CONNECTED) {


_xmppClient.addHandler(_eventHandler, null, 'message', null, null, null);
_xmppClient.addHandler(_presenceHandler, null, 'presence', null, null, null);

// To keep the user session alive on Openfire
setInterval(function () {

console.log("Domain", _domain);

_xmppClient.send($pres().tree());
return true;
}, 12000);

}
}

Regards,

Pravin

 

 

 

6 Replies 6

dhiarumu
Cisco Employee
Cisco Employee

Hi @pravin1,

What is the error your getting? Is the whole code snippet printed on the console log? could you please elaborate more?

 

Regards

Dhina

Basically the XMPP client session disconnects after few minutes or an hour. XMPP client connection gets reset and  print following whole code (OnConnect function) in browser console.

function _onConnect(status) {
console.log("_onConnect() - XMPP client onCONNECT fired");
// THESE STATUS CODES ARE SELF EXPLANATORY, for more info check the official documentation of Strophe Library.
if (status === Strophe.Status.ERROR) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.ERROR);
} else if (status === Strophe.Status.AUTHFAIL) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.AUTHFAIL);
} else if (status === Strophe.Status.CONNECTED) {


_xmppClient.addHandler(_eventHandler, null, 'message', null, null, null);
_xmppClient.addHandler(_presenceHandler, null, 'presence', null, null, null);

// To keep the user session alive on Openfire
setInterval(function () {

console.log("Domain", _domain);

_xmppClient.send($pres().tree());
return true;
}, 12000);

}
}

 

Please let me know if you need any logs or details from my end.

Regards,

Pravin

 

dhiarumu
Cisco Employee
Cisco Employee

Hi Pravin,

Could you please share more details about which Finesse version you are using?

More details about how to connect with managing thirdparty notifications can be found here: https://developer.cisco.com/docs/finesse/#!managing-notifications-in-third-party-applications/managing-notifications-in-thirdparty-applications

Thanks

We are using Cisco UCCX 12.5.1 SU  lab with Finesse. Please let me know if you need any more information.

Following is the full code for WebSocket connection to finesse server.

function _onConnect(status) {
console.log("_onConnect() - XMPP client onCONNECT fired");

// THESE STATUS CODES ARE SELF EXPLANATORY, for more info check the official documentation of Strophe Library.
if (status === Strophe.Status.ERROR) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.ERROR);
} else if (status === Strophe.Status.AUTHFAIL) {
console.log("_onConnect() - XMPP client about to reset because of status:" + Strophe.Status.AUTHFAIL);
} else if (status === Strophe.Status.DISCONNECTED){
console.log("STATUS:"+status)
_eventConnect();
} else if (status === Strophe.Status.CONNECTED) {

console.log("Connected");
_xmppClient.addHandler(_eventHandler, null, 'message', null, null, null);
_xmppClient.addHandler(_presenceHandler, null, 'presence', null, null, null);
// We send online presense to the server. (pub sub concept)
_xmppClient.send($pres().tree());

// To keep the user session alive on Openfire
setInterval(function () {

console.log("Domain", _domain);
_xmppClient.ping.ping(_domain,
function () {},
function () {}, 20000);
return true;

}, 20000);

_finesse.sysInfo(false,
(data)=>{
console.log("sysInfo");
sysInformation = data;
console.log(data);
_finesse.sysInfo(true, _sysInfohandler, _sysInfohandler);
setTimeout(()=>{
console.log("----------------");
console.log(data);
sysInformation = data;
},30);

},
()=>{console.log("sysInfo")});
}
}

/**
* Establish websocket connection using the strophe library.
*/
function _eventConnect() {
//var adlCti for event handling for CRM;
_adlCti = new ADLCTI();
console.log("_eventConnect - ID:" + _username + ", domain:" + _domain + ", resource:" + _extension);

//Construct JID with username and domain.
var jid = _username + "@" + _domain + "/" + _extension,
scheme = "",
bindURL = "";
console.log("_eventConnect - XMPP client JID for connection = " + jid);
scheme = window.location.protocol === "https:" ? "wss:" : "ws:";
bindURL = "/ws/";
// Connection URL for websocket
var connectURL = scheme + "//" + window.location.host + bindURL;
console.log("_eventConnect - XMPP client connect url = " + connectURL);

//console.log("_eventConnect - Initialize Strophe XMPP client");
//Create Strophe connection object.
_xmppClient = new Strophe.Connection(connectURL, {protocol: "wss"}, {sync: true}, {'keepalive':true});

console.log("_eventConnect - Strophe XMPP client created");

//console.log("_eventConnect - Calling Strophe XMPP connect");
//Connect to Websocket connection.
try{
_xmppClient.restore(jid);
}
catch(err){
console.log("CONNECTION called---");
_xmppClient.connect(jid, _password, _onConnect);
}

}

We are using Cisco UCCX 12.5.1 SU  lab with Finesse. Please let me know if you need any more information.

Also attaching Browser console logs when websocket connection disconnects. 

We are using Cisco UCCX 12.5.1 SU  lab with Finesse. Please let me know if you need any more information.

Regards,

Pravin 

Hi Pravin,

I have seen the logs and i dont see any error in it. I have seen the way finesse desktop uses this code and it looks similar. Attaching the code snippet for reference, Please check.

For creating the strophe connection, {protocol: "wss"}, {sync: true}, {'keepalive':true} parameters are not passed 

var _xmppClient = new Strophe.Connection("wss://finesse.auto.xyz:8445/ws/");

_xmppClient.connect("1001@finesse.auto.xyz/desktop", "pwd", _onConnect);

 

function _onConnect(status,errorCondition) {

        console.log("EventTunnel._onConnect() - XMPP client onCONNECT fired");

        var unloadEvent = "unload";

        var statusStr;

        _isConnected = false;

        console.log("EventTunnel._onConnect() - XMPP client onConnect status is: ", status , errorCondition);

        if (status === Strophe.Status.ERROR && errorCondition === "conflict") {

           statusStr = "conflict";

           _initPresence = false;

          _resetConnection();

}

        else if (status === Strophe.Status.AUTHFAIL) {

           statusStr = "unauthorized";

           _initPresence = false;

            _resetConnection();

}

else if (status === Strophe.Status.CONNECTING) {

    _xmppClientStatus = Strophe.Status.CONNECTING;

} else if (status === Strophe.Status.CONNFAIL) {

    _xmppClientStatus = Strophe.Status.CONNFAIL;

} else if (status === Strophe.Status.DISCONNECTING) {

    _xmppClientStatus = Strophe.Status.DISCONNECTING;

} else if (status === Strophe.Status.DISCONNECTED) {

    statusStr = "disconnected";

            _xmppClientStatus = Strophe.Status.DISCONNECTED;

             window.removeEventListener(unloadEvent, _unload);

            _initPresence = false;

            console.log("EventTunnel._onConnect() - XMPP client about to reset because of status:" , statusStr);

            _resetConnection();

} else if (status === Strophe.Status.CONNECTED) {

    statusStr = "connected";

            console.log("EventTunnel._onConnect()- XMPP client about to reset because of status:" , statusStr);

    _xmppClientStatus = Strophe.Status.CONNECTED;

           window.addEventListener(unloadEvent, _unload);

    // We add a listener that will catch the opposite user's msgs

  _xmppClient.addHandler(_eventHandler, null, 'message', null, null,  null);

  _xmppClient.addHandler(_presenceHandler, null, 'presence', null, null,  null);    

            if (_notificationConnectionType.toLowerCase() === "websocket") {

        _startPing();

            }

    _xmppClient.send($pres().tree());

            // Do not send the connected status immediately. The

            // connected status is gated on the strophe client's

            // connectedUser presence because OpenFire will not route events to

            // the session for this user unless their presence is available.

            _checkToSendConnected();            

            // Set to undefined so that it will not be sent to the

            // parent frame just yet.

            statusStr = undefined;

            _isConnected = true;

}

}

Ping is done for every 10sec.

Regards,

Ravi