1
votes

I am new in ejabberd and Strophe. I am developing web-chat application using strophe client and ejabberd xmpp server.

Connection prebind in backend:

XMPPPrebind xmppPrebind = new XMPPPrebind(boshHost, xmppDomain,
                boshUri, resource, boshPort, useSsl, debug);
xmppPrebind.connect(username, password);
xmppPrebind.auth();
SessionInfo sessionInfo = xmppPrebind.getSessionInfo();

Attach connection in strophe on UI:

connection = new Strophe.Connection(BOSH_SERVICE);
connection.attach(userjid + '@' + domain, sid, rid, onConnect);
connection.addHandler(onMessage, null, 'message', null, null, null);
......

On the page load I make new ejabberd connection from back-end and get sid and rid. Attaching connection using sid and rid in strophe on UI. It is working fine, no issue.

But when user open new tab in browser for same user, its cause new ejabberd connection with new sid and rid, then the old tab getting disconnected.

How can I keep alive connection in both tabs or multiple tabs so that user can send/receive message in all tab ?

I searched on google but not found steps to enable this feature in web chat. Also try to understand : http://xmpp.org/extensions/xep-0280.html

I am blocked here, Please help. Thanks

1

1 Answers

3
votes

You need to generate a new unique resource per browser tab. Using the same resource name will disconnect previously connected resources, by design.