Take the 2-minute tour ×

I am working on an XMPP web application which need to include session attachment. I am using Openfire XMPP server. I have successfully implemented the server side attachments where the session is created and I get the sid and rid of a session. Unfortunately, I am stuck in the next part.

As I know, after getting the sid and rid, I need to use the Strophe.Connection.attach() to attach strphe to the existing session. After that I am making an IQ request which gets the correct response from the server. However, I am not getting any changes in the status i.e. the app is neither connected nor attached and hence I am not able to do anything. After the IQ request, the server responds on time with the normal message and then in the next request, I get a 403 forbidden error and the connection is terminated.

Here is the code:

var BOSH_SERVICE = 'http://localhost/cosys-rtw/';
var connection = null;
var sid = "";
var rid = 0;
function notifyUser(msg) 
    if (msg.getAttribute('from') == "testuser1@ghost/pingstream") {
        var elems = msg.getElementsByTagName('body');
        var body = elems[0];
return true;

 function onConnect(status)
if (status == Strophe.Status.ATTACHED) {
    $('#notifications').html('<p class="welcome">Hello! Any new posts will    appear below.</p>');

$(document).ready(function () {
            resp = jQuery.parseJSON(response);
            window.sid = resp.sid;
            window.rid = resp.rid;

 function prepareStrophe(){
jid = "testuser1@ghost";
connection = new Strophe.Connection(BOSH_SERVICE);
connection.attach(  jid,window.sid,window.rid,null);
connection.sendIQ( $iq({to:Strophe.getDomainFromJid(jid),type:"get"})
                        if (status == Strophe.Status.ATTACHED) {

I get the follwoing response to the IQ request:

<body xmlns="http://jabber.org/protocol/httpbind">
 <iq id="6173:sendIQ" xmlns="jabber:client" type="result" from="ghost"    to="testuser1@ghost/6b8bfe07">
 <identity category="server" name="Openfire Server" type="im"></identity>
 <identity category="pubsub" type="pep"></identity>
 <feature var="http://jabber.org/protocol/pubsub#delete-nodes"></feature>
 <feature var="http://jabber.org/protocol/pubsub#purge-nodes"></feature>
 <feature var="http://jabber.org/protocol/disco#info"></feature>
 <feature var="http://jabber.org/protocol/rsm"></feature>

This response does say that the session is valid. Am I right? I am not able to figure this thing so now I am handing this to the community. By the way -- Merry Christmas

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I think that I have got something here that I would like to share if anyone has the same problem. This thread on ignite realtime http://community.igniterealtime.org/thread/33004 discusses about this issue. The settings mentioned there did work for me.

share|improve this answer

Your Answer


