I recently encountered another problem with Strophe.js application: Even though I am actively chatting with user B (sending proper xml according to the spec, including <active> and stuff) it happens that server informs user B that I become unavailable.
At the moment logic looks like this:
- connect
- send initial presence stanza
- update status (away/dnd) when needed
- start pinging server every 10s
- user is able to chat now
Pinging is done in order to ensure server didn’t crush, it’s know and widely used technique (using <iq…>).
Every message sent by users looks like this:
<message from="me@server.ltd" to="friend@server.ltd" type="chat" id="randomID" xmlns="jabber:client">
<active xmlns="http://jabber.org/protocol/chatstates" />
<body>Text</body>
</message>
Do you know this problem and any possible solution for that?
This problem can be resolved by using Strophe.roster plugin. The issue is related to the fact that when user re-logged to the server new session was created. After some time (60s supposedly), the old session expired and server broadcasted info that the user is gone.
The solution requires storing resources created by each contact when they log in and removing them when user is gone. User can be assumed to be offline if and only if there are no more resources.
I also added new functions to the Strophe.roster eg: