socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

share the same socket.io channel among browser tabs

Open soleiljy opened this issue 15 years ago • 4 comments

Hi,

It could be a dumb question, but i would like to get some help.

Let's suppose a browser opened with 100 tabs. In the current socket.io implementation, i think each tab would make its own connection with the server, and therefore 100 different socket.io channels would be generated.

Question: Is there any way to share the same socket.io channel among browser tabs which use the same (domain) cookie?

thanks in advance

soleiljy avatar Oct 25 '11 20:10 soleiljy

You can't share one connection between different tabs in browser. It's a browser limitation, not a socket.io client. So, you can't use same socket.io channel for all tabs.

cris avatar Oct 28 '11 00:10 cris

Not even if you could somehow authenticate with the same user id/session id ?

toxik avatar Nov 10 '11 21:11 toxik

No. The tabs can't effectively pass messages between one another, and they aren't told when other tabs are closed.

Even if you solved that, your feature would require rearchitecting a lot of the client and the server. Its not worth fixing simply to make 100 tabs use less RAM.

josephg avatar Nov 14 '11 14:11 josephg

https://www.npmjs.com/package/socketio-shared-webworker is a fork of socket.io that does exactly what is wanted here. Using the webworker it is able to have multiple tabs that can communicate between one another.

tankerkiller125 avatar Feb 17 '18 17:02 tankerkiller125