Share strophe connection

104 views
Skip to first unread message

Alexander Vlasov

unread,
Mar 14, 2018, 11:13:21 AM3/14/18
to Strophe
Is it possible to share single conection to jabber server between several browser tabs?
I want to send messages via connection in another tab(s). It also can decrease number of connections to server.

JC Brand

unread,
Mar 14, 2018, 11:22:34 AM3/14/18
to Alexander Vlasov, Strophe
Not that I'm aware of.


--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Jack Moffitt

unread,
Mar 14, 2018, 11:24:41 AM3/14/18
to strophe, Alexander Vlasov
A long time ago I experimented with doing Strophe in a shared web
worker and then connecting to that from each tab. It should work fine,
but the problem I ran into is that you can't pass DOM nodes across the
boundary. You could try that, but you'll need to translate the
messages to/from DOM into something else to pass them back and forth.

jack.
> --
> You received this message because you are subscribed to the Google Groups "Strophe" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to strophe+u...@googlegroups.com.
> To post to this group, send email to str...@googlegroups.com.
> Visit this group at https://groups.google.com/group/strophe.
> For more options, visit https://groups.google.com/d/optout.

Rafal Szczodruch

unread,
Apr 9, 2021, 12:45:01 PM4/9/21
to Strophe
Hi. I saw there was SharedWorker support added in 1.4.1. Can anybody tell me how to use it? I was using past versions of strophe.js successfully, but now I wanted to optimize the chat, so it maintains only one connection per browser window.
I have build latest version of strophe with npm install (node -v results with 14.16.0).
I have included strophe with importScripts("strophe.umd.js"), but i get an error in browser console:
"Error: You must install the "xmldom" package to use Strophe in nodejs."
I believe xmldom is added as a dependency in package.json, so it should be included in the build. 

Can you anybody give me a little bit of information how to use strophe.js with shared workers?

Maqsood Ahmed

unread,
Jul 6, 2021, 2:07:06 PM7/6/21
to Strophe
Hi, SharedWorker not working. I did these steps. then its even not connecting with server also there is not any console error. Please help. Thanks

first copied src/shared-connection-worker.js into my project src directory

then changed Strophe.Connection options
const connection = new Strophe.Connection(config.serviceUrl, {
    protocol: XMPP_PROTOCOL,
    withCredentials: true,
    mechanisms: [Strophe.SASLExternal],
    worker: './shared-connection-worker.js'
});
Reply all
Reply to author
Forward
0 new messages