0
votes

I have a web chat application. I am using BOSH, Openfire, and Strophe. Everything is working great except when page refreshes. I save the user information (JID, RID, SID) using cookies before page refresh. However, when the connection is reset, all online users will be displayed but when you send messages to a client in succeeding order it will automatically go UNAVAILABLE although the session is still alive.

EDIT:

$(window).bind('onunload', function () {
    if(connection !== null){
        connection.pause();
        set_cookies();
    }else{
        del_cookies();
    }
});

After refresh, the connection should resume using the Attach() function. the list of all online contacts will be display but after some seconds it will go unavailable.

1
Can you post requests and responses made after page reload?Milos Jovanovic
hi the actual code or the console traffic?leeshin

1 Answers

2
votes

You can get this problem by saving rid on creating connection, rid gets updated on every request, xmpp server usually has some window for the rids, so it's important to keep rid updated in the cookies.

Try to update rid on each BOSH request that strophe makes. This can be done by inserting rid-saving code to xmlOutput method of the connection object:

conn.xmlOutput = function(body) {
    var rid = $(body).attr('rid');
    // save rid to cookies
}