[jdev] Detecting multiple resource connections
Ralph Meijer
jabber.org at ralphm.ik.nu
Wed Apr 27 06:21:34 CDT 2005
On Wed, Apr 27, 2005 at 01:08:19PM +0200, Jesus Cea wrote:
> I would suggest to "JEP" a non destructive bind. That is, if the
> resource is already in use, the bind would fail.
>
> But since a server can be hours with undetected failed connections,
> perhaps a more sensible approach could be to bind with a random
> resource, send a stanza to the demanded resource, and if the resource is
> offline or not answers in X seconds, rebind to it.
Well, section 7 of RFC 3920, that discusses resource binding, does mention
a way to have the server assign a new resource. That is, you don't request
a specific resource, but the server makes one up for you. Excerpt:
If the client wishes to allow the server to generate the resource
identifier on its behalf, it sends an IQ stanza of type "set" that contains
an empty <bind/> element:
Client asks server to bind a resource:
<iq type='set' id='bind_1'>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
</iq>
A server that supports resource binding MUST be able to generate a resource
identifier on behalf of a client. A resource identifier generated by the
server MUST be unique for that <node at domain>.
If the client wishes to specify the resource identifier, it sends an IQ
stanza of type "set" that contains the desired resource identifier as the
XML character data of a <resource/> element that is a child of the <bind/>
element:
Client binds a resource:
<iq type='set' id='bind_2'>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
<resource>someresource</resource>
</bind>
</iq>
Once the server has generated a resource identifier for the client or
accepted the resource identifier provided by the client, it MUST return an
IQ stanza of type "result" to the client, which MUST include a <jid/> child
element that specifies the full JID for the connected resource as
determined by the server:
Server informs client of successful resource binding:
<iq type='result' id='bind_2'>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
<jid>somenode at example.com/someresource</jid>
</bind>
</iq>
The text further mentions that a client may get an error back when a resource
is already in use, and the server doesn't allow rebinding. There is also some
text about the fact that a server may alter the suggested resource, so the
actual bound resource must always (!) be taken from the resulting iq. It could
be used to just give out another resource, if the requested resource was
already taken
--
Groetjes,
ralphm
More information about the JDev
mailing list