Problem "Invalid SID" before and after page refresh

2,648 views
Skip to first unread message

juulh009

unread,
Oct 15, 2010, 8:58:03 AM10/15/10
to Strophe
I'm using Strophe to connect to my Openfire XMPP server. The user
fills in his JID and password and a connection is set up to my server.
I want, that it is possible to surf across the website without the
need to re-authenticate. To make this possible i found out that
strophe has a method named "attach" that makes this possible. But i'm
having problems:

first: The server responds with "invalid SID" when strophe sends the
disconnect
second: After the web page is refreshed the attach respond is "invalid
SID"

I've no idea what's the problem. the RID number is ok and the SID is
the same.

Debug data:

http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 203
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277873' xmlns='http://jabber.org/protocol/httpbind'
to='clubs' xml:lang='en' wait='60' hold='1' content='text/xml;
charset=utf-8' ver='1.6' xmpp:version='1.0'
xmlns:xmpp='urn:xmpp:xbosh'/>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:17 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 577
Via: 1.1 localhost
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 193
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277874' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
mechanism='PLAIN'>anV1bEBjbHVicwBqdXVsAFZhaXIwbmVl</auth></body>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:17 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 108
Via: 1.1 localhost
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 156
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277875' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52' to='clubs' xml:lang='en' xmpp:restart='true'
xmlns:xmpp='urn:xmpp:xbosh'/>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:17 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 334
Via: 1.1 localhost
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 197
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277876' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'><iq type='set' id='_bind_auth_2'
xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/
></iq></body>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:17 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 210
Via: 1.1 localhost
Keep-Alive: timeout=5, max=97
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 206
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277877' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'><iq type='set' id='_session_auth_2'
xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-
session'/></iq></body>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:17 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 184
Via: 1.1 localhost
Keep-Alive: timeout=5, max=96
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 214
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277878' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'><iq type='get' xmlns='jabber:client'
id='8013:sendIQ'><query xmlns='jabber:iq:roster'/></iq><presence
xmlns='jabber:client'/></body>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:18 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 159
Via: 1.1 localhost
Keep-Alive: timeout=5, max=95
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 83
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277879' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'/>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:40 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 57
Via: 1.1 localhost
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 83
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277880' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'/>
HTTP/1.1 200 OK
Date: Fri, 15 Oct 2010 12:41:40 GMT
Server: Jetty(6.1.x)
Content-Type: text/xml; charset=utf-8
Content-Length: 103
Via: 1.1 localhost
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 158
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277881' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52' type='terminate'><presence xmlns='jabber:client'
type='unavailable'/></body>
HTTP/1.1 404 Invalid SID.
Date: Fri, 15 Oct 2010 12:41:40 GMT
Server: Jetty(6.1.x)
Content-Type: text/html; charset=iso-8859-1
Content-Length: 1402
Via: 1.1 localhost
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
----------------------------------------------------------
http://www.sidproblem.com/http-bind

POST /http-bind HTTP/1.1
Host: www.sidproblem.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.10)
Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Length: 83
Content-Type: text/plain; charset=UTF-8
Cookie: forum_tree=forum_tree;
clubsSession2=knbn8gogq2992v7uli2bs1j0v3
Pragma: no-cache
Cache-Control: no-cache
<body rid='1964277882' xmlns='http://jabber.org/protocol/httpbind'
sid='5d0f8d52'/>
HTTP/1.1 404 Invalid SID.
Date: Fri, 15 Oct 2010 12:41:43 GMT
Server: Jetty(6.1.x)
Content-Type: text/html; charset=iso-8859-1
Content-Length: 1402
Via: 1.1 localhost
Keep-Alive: timeout=5, max=91
Connection: Keep-Alive
----------------------------------------------------------

Karan Ahuja

unread,
Oct 15, 2010, 11:25:54 AM10/15/10
to str...@googlegroups.com
Yes , we are also facing the exact same problem .
will be gr8 if we get pointers to this as this is the only roadblock with our ecommerce realtime shop together app using strophe :)

Eagerly awaiting replies .

Thanks and regards ,

Karan Ahuja
www.kodeplay.com




--
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.


juulh009

unread,
Oct 18, 2010, 5:08:54 AM10/18/10
to Strophe
type='terminate' causes openfire to close the session. after a session
has been closed it will no longer accept new connections on the
session ID.

wimme

unread,
Oct 18, 2010, 6:38:27 AM10/18/10
to Strophe
You can bypass this by implementing a connection manager. We faced the
same problem, and i've implemented punjab. Punjab keeps the connection
open.

juulh009

unread,
Oct 18, 2010, 9:38:11 AM10/18/10
to Strophe
I found another solution. The problem is that Strophe sends a
type='terminate' when refreshing the page.
You can bypass this with this piece of smelly code:

$.bind('beforeunload', function(){
connection.pause();
connection._requests = new Array();
});

Vineet Naik

unread,
Oct 18, 2010, 10:41:12 AM10/18/10
to str...@googlegroups.com
Hi,
 
I am facing the exact same problem. guess will have to try punjab after all.. But here is a behaviour i observed by keeping the firebug console persistent.. may be this helps someone to point out if i am missing anything

1) when a page is refreshed it sends an aborted request which appears in red colour in the console

2) then a normal request is sent with the same sid but the rid is the same as the one for the previous request which was aborted. (I think same rid may also be the problem although the request was aborted). But it does yeild a response, 

<body xmlns="http://jabber.org/protocol/httpbind"></body>

3) Now there is a normal request again with an incremented rid this time and same sid. But this is what i get in the response

<body xmlns="http://jabber.org/protocol/httpbind" type="terminate" condition="policy-violation"></body>

4) The next request is the one with type="terminate" . The response to this Error 404 Invalid SID. The request again appearing in red colour. Then the page refreshes and gives the invalid SID error again although the SID is staying the same.

I connect in php using the bosh connection class written by wimme in one of the previous threads and then attach using stophe. It works perfectly for the first time. After refreshing the page it shows invalid SID error in console. The RID is not a problem as most of the time its the exact incremented value sometimes differing by 2 - 4 which is within the range (correct if wrong).

I tried the beforeunload hack mentioned by juulh009 but its not working for me.. 


--
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,
Oct 18, 2010, 11:22:51 AM10/18/10
to str...@googlegroups.com
> I found another solution. The problem is that Strophe sends a
> type='terminate' when refreshing the page.
> You can bypass this with this piece of smelly code:

Strophe does not have any baked in actions for page termination.
Strophe should only disconnect if some user code calls disconnect() or
some otherwise fatal error has occurred.

I have not currently implemented a detach() command, which is the
source of this confusion. In the meantime, calling pause() will
prevent Strophe from sending further data, and you should be able to
reload the page and attach() without problems.

jack.

Jack Moffitt

unread,
Oct 18, 2010, 11:30:06 AM10/18/10
to str...@googlegroups.com
> 1) when a page is refreshed it sends an aborted request which appears in red
> colour in the console

I believe the browser will terminate any open XHRs when the page unloads.

> 2) then a normal request is sent with the same sid but the rid is the same
> as the one for the previous request which was aborted. (I think same rid may
> also be the problem although the request was aborted). But it does yeild a
> response,

I don't understand this part. If the page is being unloaded, Strophe
should not be able to send another request. However, Strophe will
attempt to resend any aborted request with the same payload it sent
the first time. This is legal BOSH behavior, and the BOSH connection
manager should return the same payload if it previously handled this
request. After all, the response might have gotten lost on the way
back.


> 3) Now there is a normal request again with an incremented rid this time and
> same sid. But this is what i get in the response
>>
>> <body xmlns="http://jabber.org/protocol/httpbind" type="terminate"
>> condition="policy-violation"></body>

This may be a bug in Openfire. It's BOSH connection manager
implementation is pretty restrictive it seems, and it has, by far, the
most problems if you measure by Strophe list traffic. If someone can
track down what policy was violated, I can make a determination as to
whether it's Strophe's fault or not.

> 4) The next request is the one with type="terminate" . The response to this
> Error 404 Invalid SID. The request again appearing in red colour. Then the
> page refreshes and gives the invalid SID error again although the SID is
> staying the same.

If Strophe receives a type='terminate', then the connection manager
has already invalidated the SID. Strophe should not attempt to send
more traffic, but currently it seems to. This is a minor bug that
shouldn't have any real world effects.

> I connect in php using the bosh connection class written by wimme in one of
> the previous threads and then attach using stophe. It works perfectly for
> the first time. After refreshing the page it shows invalid SID error in
> console. The RID is not a problem as most of the time its the exact
> incremented value sometimes differing by 2 - 4 which is within the range
> (correct if wrong).

The RID must be perfect in some connection managers. The BOSH spec
actually says that connection managers must wait to process data until
they have the next sequential RID. Punjab and some other managers
contain an optimization which processes data faster but relaxes the
stanza ordering requirement. In the former case, no data will be sent
if the RID you use on attach isn't the next available RID. In the
latter case, you will just shorten the window size, which is not a
huge deal most of the time.

jack.

Vineet Naik

unread,
Oct 19, 2010, 9:16:51 AM10/19/10
to str...@googlegroups.com
Hi Jack,

Thanks for replying. 
 
I don't understand this part. If the page is being unloaded, Strophe
should not be able to send another request.  

Even I am not able to figure out how these two requests are being sent after the browser aborts one request before refreshing. 

I have captured a screenshot of the the requests in the console which show exactly what I was trying to say in the previous post. It can be found here (http://kodeplay.org/strophe.png)
 
Regards,
vineet
 





Jack Moffitt

unread,
Oct 19, 2010, 12:15:10 PM10/19/10
to str...@googlegroups.com
> Even I am not able to figure out how these two requests are being sent after
> the browser aborts one request before refreshing.
> I have captured a screenshot of the the requests in the console which show
> exactly what I was trying to say in the previous post. It can be found
> here (http://kodeplay.org/strophe.png)

I wish Firebug showed the timing information. That would be good to
know. Also, can you send me the response XML as well, at least for
RIDs ending in -705 through -708.

If you could isolate this to a small test case, I could probably take
a look locally and see if I can reproduce.

jack.

Vineet Naik

unread,
Oct 21, 2010, 6:21:08 AM10/21/10
to str...@googlegroups.com
Hi Jack,

I have isolated just the attach code and uploaded a working demo here ... http://bingzy.com/juststrophe
username: jazz ; password : jazzjazz

let me know in case you also need the server side code to look into.. 

Thanks a ton.
vineet


jack.

Jack Moffitt

unread,
Dec 5, 2010, 4:01:56 PM12/5/10
to str...@googlegroups.com
> I have isolated just the attach code and uploaded a working demo here ...
> http://bingzy.com/juststrophe
> username: jazz ; password : jazzjazz

That URL seems invalid. Did this move?

jack.

Vito Tafuni

unread,
Dec 6, 2010, 3:46:37 AM12/6/10
to str...@googlegroups.com
Hi
this is my experience with attach and similars.
I put in pause the conn manager before saving to cookies sid,rid and jid
so i'm sure that they are not changed after i've saved them.
this way everything works fine
i've tryed to reload the samepage more and more times (for debug purpouse) and never had a connection problem thanks to bosh.

-Vito-






--
-----------
Tafuni Vito
vi...@vitotafuni.com
---------------------------------------------
"Verba volant, scripta manent... data corrupted"


2010/12/5 Jack Moffitt <ja...@metajack.im>

jack.

Vineet Naik

unread,
Dec 6, 2010, 4:48:49 AM12/6/10
to str...@googlegroups.com
Hi Jack, 

Yes it has been taken down.. Anyways the problem is solved now (of course thanks to your help on another thread) .. there was some xml formatting problem in the server side connect code . Could figure it out through the punjab logs. 

However it doesn't work if directly connected to openfire without punjab.

vineet

--
Vineet Naik
 Mobile: +91 9820776899 | Blog:  http://vineetnaik.me | Skype: vineet.naik 




Vineet Naik

unread,
Dec 6, 2010, 5:01:44 AM12/6/10
to str...@googlegroups.com
Hi Jack, 

Do you want me to upload it back ? I can do that in case you want to have a look at it

vineet

Jack Moffitt

unread,
Dec 6, 2010, 11:32:41 AM12/6/10
to str...@googlegroups.com
> Do you want me to upload it back ? I can do that in case you want to have a
> look at it

No, that's alright. I'm glad you found the solution.

Note that I will be adding a detach() function soon that will
basically do what you discovered. pause() and give back the correct
RID.

jack.

Jay J

unread,
Aug 28, 2014, 7:29:16 PM8/28/14
to str...@googlegroups.com
Hi Vineet,

What was the solution? I am experiencing a similar issue with Openfire + Punjab

Thanks
Reply all
Reply to author
Forward
0 new messages