Should Presence Be Broadcast to an XMPP Server When Attaching (not connecting) via Strophe?

StackOverflow https://stackoverflow.com//questions/10659557

  •  11-12-2019
  •  | 
  •  

Question

The XMPP spec states that the client should broadcast presence upon connecting to an XMPP server. Strophe has two methods to "connect" to an XMPP server: connect and attach. Connect does a full authorization and attach is for reconnecting to a pre-existing connection. When using attach, should the client broadcast presence to the server?

In my testing, it appears that if I do not broadcast presence on attach, the client does not receive messages (presence, message, or otherwise) from other users, and if the client attempts to send any stanzas, he is immediately disconnected by the server. It's as if the server has no idea the user is connected without the presence broadcast.

This seems as if I answered my own question, however, I'm wondering if there is perhaps a bug in the server or if I'm doing something wrong or is this expected behavior?

Was it helpful?

Solution

There is a bug somewhere - attaching is literally attaching - you are continuing the original session. The server doesn't even know it happened!

Something to watch out for - if you have the old code still open, and you have multiple things using the same session, you could easily end up with something like you describe.

If you're still stuck, it might be useful to see some code, or at least a log of the attached session (e.g. the disconnection from the server - what error does it give, etc.?).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top