Getting RID and SID from Smack

888 views
Skip to first unread message

Rich

unread,
Mar 2, 2011, 12:36:23 PM3/2/11
to Strophe
Hi

I've just been trying to use Smack to setup an XMPP connection to pass
to strophe to use the .attach() function. Can anyone tell me how to
get at the RID as I'm assuming making up a random one won't work?
Also I have tried the following code:

XMPPConnection connection = new XMPPConnection("localhost");
connection.connect();
connection.login("user@localhost", "password");

to setup the connection, and

<script type="text/javascript">
var SID = "<%=connection.getConnectionID()%>";
var USERID = "<%=connection.getUser()%>";
</script>

to pass the sid and user id to the attach function. I'm assuming that
connection.getConnectionID() IS the sid? When I run the attach I am
getting the following error:

the server responded with a status of 404 (Invalid SID.)

The request payload looks like the following:

<body rid='12343424' xmlns='http://jabber.org/protocol/
httpbind' sid='b78cd76'/>

Thanks in advance,
Rich

Jack Moffitt

unread,
Mar 2, 2011, 12:45:23 PM3/2/11
to str...@googlegroups.com
> to pass the sid and user id to the attach function.  I'm assuming that
> connection.getConnectionID() IS the sid?  When I run the attach I am
> getting the following error:
>
>          the server responded with a status of 404 (Invalid SID.)

If you could paste the wire traffic from the XMPP session when it's
first established and then from strophe when it tries to attach, we
can determine if the SID is correct.

I'm not sure how to get the RID from Smack, but perhaps someone else
on the list will know.

jack.

Ilya Braude

unread,
Mar 2, 2011, 1:50:53 PM3/2/11
to str...@googlegroups.com

> XMPPConnection connection = new XMPPConnection("localhost");
> connection.connect();
> connection.login("user@localhost", "password");
>

You have to initiate a BOSH session with smack and pass the sid/rid
parameters to strophe. You can't just use a regular XMPPConnection.
Check out this version of smack that has BOSH support, and use a
BOSHConnection instead:

https://github.com/rtreffer/smack


Ilya

Daniel Dormont

unread,
May 22, 2013, 2:24:29 PM5/22/13
to str...@googlegroups.com, rich.u...@gmail.com
Smack and Strophe can't work together in this way. Smack is an ordinary XMPP client library. It doesn't speak BOSH, so the concept of SID and RID just aren't applicable in Smack.

Instead, you'll need to use whatever mechanism your XMPP server provides (directly or through an add-on) to pre-bind a BOSH connection and get the SID and RID for that.

-Dan


On Wed, May 22, 2013 at 1:30 PM, <ma...@chopperexchange.com> wrote:
Did you ever find a solution? I'm having the same issue.
 
Thanks,
Mark

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

Daniel Dormont

unread,
May 24, 2013, 11:33:00 AM5/24/13
to str...@googlegroups.com, Rich Upshall
Alternately you could use a library like Jbosh; https://kenai.com/projects/jbosh/pages/Home

and just make sure that you close the connection on the server side without sending the intial presence (assuming Jbosh allows that - I haven't used it myself). Then just pick up the SID and last RID and you're good to go - you may have to increment the RID by 1 depending on the details.
Reply all
Reply to author
Forward
0 new messages