Wrox Programmer Forums
|
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2010, 01:55 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

You skipped the rid ending in -2. The fact that -1 is sent twice is not a big deal. What is happening is that strophe is detecting the aborted request and trying to send it again. This is non-fatal and the connection manager will simply send the cached response it generated previous.

But skipping an RID is going to make the connection manager terminate the session, which will give you a 404.
 
Old September 13th, 2011, 05:52 AM
Registered User
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Failed to attach connection

Hi,
In my web application, I want to maintain the same Strophe connection across multiple pages. For that reason, I'm using attach method. On first page (when I hit the site), it creates the connection, however, when I move to any other page it attaches the connection, but gives error just after attaching. Please refer following code:

Code:
$(document).bind('connect', function (ev, data) {
    var jid = $.jStorage.get('JID', null);
    var sid = $.jStorage.get('SID', null);
    var rid = $.jStorage.get('RID', null);
    if ((jid != null) && (sid != null) && (rid != null)) {
        var conn = new Strophe.Connection("http://localhost:5280/xmpp-httpbind");
        conn.attach(jid, sid, rid, function () {
            alert('Connection attach success.');
            Gab.connection = conn;
        });
    }
    else {
        var conn = new Strophe.Connection("http://localhost:5280/xmpp-httpbind");
        conn.connect(data.jid, data.password, function (status) {
            if (status === Strophe.Status.CONNECTED) {
                $(document).trigger('connected');
            } else if (status === Strophe.Status.DISCONNECTED) {
                $(document).trigger('disconnected');
            }
        });
        Gab.connection = conn;
    }
});
And

Code:
$(window).unload(function () {
    if (Gab.connection != null) {
        Gab.connection.pause();
        $.jStorage.set('JID', Gab.connection.jid);
        $.jStorage.set('SID', Gab.connection.sid);
        $.jStorage.set('RID', Gab.connection.rid);
    } else {
        $.jStorage.flush();
    }
//    Gab.connection = null;
    alert('paused/disconnected');
});
Thanks for your help.
 
Old September 13th, 2011, 03:33 PM
Authorized User
 
Join Date: Feb 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mayur.tendulkar View Post
[...] when I move to any other page it attaches the connection, but gives error just after attaching.
Could you please specify the error?
 
Old September 13th, 2011, 03:55 PM
Registered User
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply. Well, I don't see any error in code as such. I get error in 'console' window in firebug.

=====================================
When page is normally loaded (first load)

POST http://localhost:5280/xmpp-httpbind 200 OK
142ms
POST http://localhost:5280/xmpp-httpbind 200 OK
121ms
=====================================

When page is refreshed or moved to another page

POST http://localhost:5280/xmpp-httpbind 200 OK
15ms
POST http://localhost:5280/xmpp-httpbind 404 Not Found
10ms
=====================================

One more thing, it continuously shows the Connection attached message, which means, connection attach callback is firing again and again.
Mainly, I don't want client (like GTalk/Pandoin) to show notifications whenever user moves to any other page and maintain the same connection across pages.
Please help.
Thanks is advance.
 
Old September 14th, 2011, 04:55 AM
Registered User
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by metajack View Post
You skipped the rid ending in -2. The fact that -1 is sent twice is not a big deal. What is happening is that strophe is detecting the aborted request and trying to send it again. This is non-fatal and the connection manager will simply send the cached response it generated previous.

But skipping an RID is going to make the connection manager terminate the session, which will give you a 404.
Can you explain it in more details? I'm facing the same issue.

Thanks
 
Old January 19th, 2012, 01:08 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

Sending the same RID multiple times is allowed by the spec. The connection manager should send the exact same response if it saw that RID before. If you send a RID that not one it has seen recently and it's not the last one it has seen + 1, then it is considered "out of window" and the connection is terminated. This is done as a security measure to prevent other people from guessing your SID/RID and hijacking your connection.

You can find more information in XEP-0124:
http://xmpp.org/extensions/xep-0124.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to simulate connection problems FileFound General .NET 3 August 12th, 2008 03:30 PM
Database Connection Problems Roy Ng Dreamweaver (all versions) 3 August 15th, 2005 09:36 AM
Connection problems after installing VS 2003 dukie VS.NET 2002/2003 7 October 31st, 2004 01:41 PM
Problems with Sqlcommand.Connection.Open() leion General .NET 4 March 18th, 2004 12:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.