Immediately disconnected when refreshing the browser after a connection has been made

102 views
Skip to first unread message

Gabe Hollombe

unread,
Jan 12, 2010, 5:20:10 PM1/12/10
to Strophe
Hey all,

I'm trying to understand what's going on here, and would appreciate
any insights any of you can share. My situation is this:

1. I can get connected to my XMPP server over BOSH using Strophe just
fine, and everything works perfectly. I have a page that
automatically connects me on page load.

2. However, if I refresh my browser, Strophe connects again to my
XMPP server (using the same credentials as its previous connection
attempt that worked above, in step 1), but then is immediately
disconnected.

Is my XMPP server not happy with the fact that a second connection
with the same JID is being created before the first one times out?

Here's all the lines from my ejabberd log file during a sample session
to demonstrate the problem. I've annotated it with #--comments--:


#=================
# START THE SERVER
#=================
=INFO REPORT==== 13-Jan-2010::09:02:03 ===
I(<0.40.0>:ejabberd_app:69) : ejabberd 2.1.1 is started in the node
ejabberd@localhost


#=================
#LOAD MY PAGE AND HAVE STROPHE CONNECT
#=================

=INFO REPORT==== 13-Jan-2010::09:02:21 ===
I(<0.377.0>:ejabberd_listener:229) : (#Port<0.420>) Accepted
connection {{192,168,0,148},59949} -> {{192,168,0,148},5280}

=INFO REPORT==== 13-Jan-2010::09:02:21 ===
I(<0.378.0>:ejabberd_http:137) : started: {gen_tcp,#Port<0.420>}

=INFO REPORT==== 13-Jan-2010::09:02:21 ===
I(<0.380.0>:ejabberd_c2s:566) : ({socket_state,ejabberd_http_bind,
{http_bind,<0.379.0>,{{192,168,0,148},59949}},ejabberd_http_bind})
Accepted authentication for 1 by ejabberd_auth_external

=INFO REPORT==== 13-Jan-2010::09:02:22 ===
I(<0.380.0>:ejabberd_c2s:816) : ({socket_state,ejabberd_http_bind,
{http_bind,<0.379.0>,{{192,168,0,148},59949}},ejabberd_http_bind})
Opened session for 1...@enterprise-g.local/10999514401263333742275944


#=================
#JOIN A MUC ROOM, PART OF MY CODE
#=================

=INFO REPORT==== 13-Jan-2010::09:02:22 ===
I(<0.382.0>:mod_muc_room:126) : Created MUC room
12...@conference.enterprise-g.local by 1...@enterprise-g.local/
10999514401263333742275944


#=================
#REFRESH THE BROWSER, CAUSING A RECONNECT WITH THE SAME CREDENTIALS AS
BEFORE
#=================

=INFO REPORT==== 13-Jan-2010::09:03:26 ===
I(<0.377.0>:ejabberd_listener:229) : (#Port<0.441>) Accepted
connection {{192,168,0,148},60002} -> {{192,168,0,148},5280}

=INFO REPORT==== 13-Jan-2010::09:03:26 ===
I(<0.383.0>:ejabberd_http:137) : started: {gen_tcp,#Port<0.441>}

=INFO REPORT==== 13-Jan-2010::09:03:26 ===
I(<0.385.0>:ejabberd_c2s:566) : ({socket_state,ejabberd_http_bind,
{http_bind,<0.384.0>,{{192,168,0,148},60002}},ejabberd_http_bind})
Accepted authentication for 1 by ejabberd_auth_external

=INFO REPORT==== 13-Jan-2010::09:03:27 ===
I(<0.385.0>:ejabberd_c2s:816) : ({socket_state,ejabberd_http_bind,
{http_bind,<0.384.0>,{{192,168,0,148},60002}},ejabberd_http_bind})
Opened session for 1...@enterprise-g.local/38609424581263333807340070


#=================
EVERYTHING LOOKS GOOD, EXCEPT THE NEXT THING THAT HAPPENS, BELOW, IS A
DISCONNECT FROM THE SERVER
#=================

=INFO REPORT==== 13-Jan-2010::09:03:28 ===
I(<0.385.0>:ejabberd_c2s:1329) : ({socket_state,ejabberd_http_bind,
{http_bind,<0.384.0>,{{192,168,0,148},60002}},ejabberd_http_bind})
Close session for 1...@enterprise-g.local/38609424581263333807340070

Gabe Hollombe

unread,
Jan 12, 2010, 5:26:31 PM1/12/10
to Strophe
All: Upon even closer inspection (as often happens right asking for
help from friends, why is this?) I believe I've discovered my probem:
I'm trying to re-enter the same MUC with the same nickname, and that's
causing an error from the server, which I'm handling with a disconnect
in Strophe.

I'm all good. Sorry for the noise here.
-g

Jack Moffitt

unread,
Jan 12, 2010, 5:26:57 PM1/12/10
to str...@googlegroups.com
> 1. I can get connected to my XMPP server over BOSH using Strophe just
> fine, and everything works perfectly.  I have a page that
> automatically connects me on page load.

Are the credentials hard-coded in the page?

> 2.  However, if I refresh my browser, Strophe connects again to my
> XMPP server (using the same credentials as its previous connection
> attempt that worked above, in step 1), but then is immediately
> disconnected.

Sounds like a resource conflict, and ejabberd is configured to boot
the new one, not the old one. Try not specifying a resource and see if
that fixes it?


> Here's all the lines from my ejabberd log file during a sample session
> to demonstrate the problem.  I've annotated it with #--comments--:

It would be far more helpful to post the Strophe rawInput/Output logs.
ejabberd will respond to the auth attempt with a failure stanza, and
that will probably tell us what is happening.

jack.

Jack Moffitt

unread,
Jan 12, 2010, 5:27:54 PM1/12/10
to str...@googlegroups.com
> All:  Upon even closer inspection (as often happens right asking for
> help from friends, why is this?) I believe I've discovered my probem:
> I'm trying to re-enter the same MUC with the same nickname, and that's
> causing an error from the server, which I'm handling with a disconnect
> in Strophe.

Ah, good that you figured it out. You should be able to handle the
nick conflict pretty easily with a new <presence> handler.

jack.

Gabe Hollombe

unread,
Jan 12, 2010, 5:33:58 PM1/12/10
to str...@googlegroups.com
I think what I'm going to do is just set my nick to the nick for the user connecting + '|' + new Date().valueOf().  I just need a way to get a user reconnected if he refreshes his browser.  Since I'm parsing all messages to the room before displaying them in my client anyway, I can just chop off the numeric datestamp from the end of the message to get their pretty nick.

-g

--
You received this message because you are subscribed to the Google Groups "Strophe" group.
To post to this group, send email to str...@googlegroups.com.
To unsubscribe from this group, send email to strophe+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/strophe?hl=en.




Jack Moffitt

unread,
Jan 12, 2010, 5:36:11 PM1/12/10
to str...@googlegroups.com
> I think what I'm going to do is just set my nick to the nick for the user
> connecting + '|' + new Date().valueOf().  I just need a way to get a user
> reconnected if he refreshes his browser.  Since I'm parsing all messages to
> the room before displaying them in my client anyway, I can just chop off the
> numeric datestamp from the end of the message to get their pretty nick.

That may solve it most of the time, but it's still possible your app
will encounter some error on join (perhaps even a duplicate nick if
another participant wants to be malicious). Just food for thought.

jack.

Gabe Hollombe

unread,
Jan 12, 2010, 5:43:15 PM1/12/10
to str...@googlegroups.com
Yep. Great points to keep in mind.  Also, I really appreciate your attentiveness.  Thanks, Jack.
-g

Reply all
Reply to author
Forward
0 new messages