Support for multiple session with the same XMPP server

Issue #94 wontfix
Markus KARG created an issue

I wonder how to correctly use Babbler API to access multiple accounts on the same XMPP server. As XmppClient.login() does not return anything, it seems as if multiple XmppClient instances have to be used. This is not optimal, as a lot of resources will get duplicated that way, which could be shared otherwise (like all the configuration, listeners, etc., and possibly the TCP connection).

So is that a wanted limitation of Babbler, of XMPP in general, or should we plan suppport for this scenario in 0.8.0-SNAPSHOT?

Comments (8)

  1. Christian Schudt repo owner

    Yes, multiple XmppClients have to be used. Each client instance represents a session with the server (account + resource). Which resources get duplicated in your opinion? Configuration and listeners can already be shared, it's only a stored in a different variable, which shouldn't be expensive.

  2. Markus KARG reporter

    I do not know XMPP very well, but I have "some" ;-) experience with other protocols. As XMPP is stateful, it reserves one TCP port on the server per client. I the same client uses several accounts (like I do, for example one for family, one for friends, one for business, and so on) you end up with n TCP ports per clients being reserved. As the limited amount of TCP ports per IP address are a major limiting factor nowadays with servers having super-bandwidths of up to 100 Gib/s per line, lots of cores and RAM, I wonder whether this old-school attempt still is a good idea. If the XMPP protocol would allow sharing one connection for multiple accounts, we could strongly reduce the TCP ports being reservered -- or in the other hand, allow servers to scale better.

    Another problem I see, but more an organizational one, is updating presence of contacts. Let's say I have 100 contacts for business, and 100 contacts for friends, there might be the case that I do business with friends, too. So for example, 10 of the friends are also existing as business contacts. In the end, I get presence updates for those twice (once from the business account, once from the friends account). I do not know if there is a way to tell XMPP that presence updates are only needed once in that case, or if the XMPP protocol insists on separating contacts such strictly.

  3. Christian Schudt repo owner

    The XMPP protocol does not allow to share one connection for multiple accounts and honstely I cannot imagine how that should work (sending multiple XMPP streams over the same TCP stream).

    For the other use case: Yes that's in the protocol as well. You get presence updates for each client. That's in the protocol as well and here I cannot imagine why and how you would merge both presences into one. The business account could have another presence as the friend account, even it's the same user/person. I think it's a good concept. E.g. afterwork the business account would be "do not disturb" and the friend account would be "available". During work, the other way. Why would you give both accounts the same presence? (the most available one??)

    Both use cases/ideas are something to discuss on the XMPP mailing list.

  4. Markus KARG reporter

    Thank you for that explanation. I understand that both are XMPP issues, and nothing we can change.

    What troubled me was the reverse way: If a friend of mine is also my business partner, my client software would receive twice HIS presence, once for each of my accounts, which is simply weird, as it is the same JID.

  5. Christian Schudt repo owner

    it's only the same bare JID (same user), but two different full JIDs (two different resources, "friend" and "business" or "home" and "office")

  6. Markus KARG reporter

    Why is it two different full JID? I have a friend which is also my business partner. He has exactly one JID (myfriend@jabber.de) and is using exactly one client (x@jabber.de/mobile). I use two different accounts to chat with him: my-business-account@jabber.de and my-private-account@jabber.de. My sole client software runs two XmppClient instances. Each of that instances requested to receive presence information for myfriend@jabber.de. So I receive twice his presence, don't I?

  7. Christian Schudt repo owner

    Yes, you receive twice his presence. But "you" are actually two different accounts/users. XMPP can't know that you are one individual using two accounts, so every account receives separate presence information. You have two different sessions with the server, even if you would use the same bare JID, but with different resources.

    I have no idea, how you would "combine" multiple XMPP streams over one TCP connection. Maybe you could propose this to the XMPP guys.

  8. Christian Schudt repo owner

    I'll close this issue, because it can't be solved in the library. XMPP does not allow to share the same connection for multiple streams/sessions.

  9. Log in to comment