Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: Professional XMPP Programming with JavaScript and jQuery
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old December 4th, 2010, 01:55 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #12 (permalink)  
Old September 13th, 2011, 05:52 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #13 (permalink)  
Old September 13th, 2011, 03:33 PM
Authorized User
Points: 71, Level: 1
Points: 71, Level: 1 Points: 71, Level: 1 Points: 71, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
  #14 (permalink)  
Old September 13th, 2011, 03:55 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #15 (permalink)  
Old September 14th, 2011, 04:55 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
  #16 (permalink)  
Old January 19th, 2012, 01:08 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:58 PM.


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