Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
ayyrk #1
Member since Jul 2007 · 92 posts
Group memberships: Members
Show profile · Link to this post
Subject: Multiple logins from same resource
How can I detect that a second login from the same resource has caused my connection to close?

Maybe I can check something in the onClose callback.

I need to do two things:  1) tell the user he is disconnected because another WM5 device connected with the account  2) prevent the device from automatically trying to reconnect because that is leading to a connection battle between the two devices.

Thanks!

-Ayyrk
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
normally the server sends a stream error and then closes the stream which looks like the following:

  1. <stream:error>
  2.    <conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
  3.    <text xmlns="urn:ietf:params:xml:ns:xmpp-streams" xml:lang="en">Replaced by new connection</text>
  4. </stream:stream>

I just added a new even OnStreamError for catching this errors. I will upload the new code in some minutes to svn so you can download it and test it.

What you also can do is generate a random Resource or let the resource null. If its null then the server generates a random resource for you. If you want to allow only a single resource logged in this is of course no solution for you.

Alex
This post was edited on 2008-04-06, 12:34 by Alex.
Avatar
ayyrk #3
Member since Jul 2007 · 92 posts
Group memberships: Members
Show profile · Link to this post
Thanks, the OnStreamError event solved my problem.

-Ayyrk
Avatar
rameshkasi #4
Member since Jun 2010 · 17 posts · Location: india
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Subject: restrict the second login from the same resource
Dear Alex,

I need to restrict the second login from the same resource.

I have implemented the OnStreamError handler to detect the second login. After some delay,This OnStreamError call is happening.

<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>


But there is no text "Replaced by new connection" from XML. Why?

Is it possible to detect while second login without delay?

Kindly reply as soon as possible.

Thanks
Ramesh Kasi
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rameshkasi:
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>

But there is no text "Replaced by new connection" from XML. Why?
The text is optional and can be different on each server implementation. You should rely on the conlict error type.

Apex
Avatar
lampo #6
Member since May 2018 · 6 posts
Group memberships: Members
Show profile · Link to this post
Is there this StreamError event implemented in the vNext? how can i get the conlict error event in vNext?
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There are different ways in MatriX vNext. But it all comes down to subscribe to the Xmpp Stream and look for the stream error stanza.

Here is a example on how you can do it directly on the XmppXElementStreamObserver of XmppClient

  1. xmppClient
  2.     .XmppXElementStreamObserver
  3.     .Where(el => el.OfType<Matrix.Xmpp.Stream.Error>())
  4.     .Where(el => el.Cast<Matrix.Xmpp.Stream.Error>().Condition
  5.         == Matrix.Xmpp.Stream.ErrorCondition.Conflict)
  6.     .Subscribe(el =>
  7.     {
  8.         // react on it
  9.     });
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS