-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limited communication between sockets over multiple sails application instances (sails.sockets.*) #3008
Comments
+1 |
+1 I'm running nginx, 4 instances and this results in an empty array on instance-B, if all my socket clients are connected to instance-A. (I'm running a node-inspector session on instance-B): (where myRoomID was used to subscribe a client to a custom room just as in OP's example) I just happened to see this issue while debugging this morning so I'll look into using sails.sockets.broadcast, but I'm not so sure about the security. Also this looks similar to #2139 ? |
Come to think of it, without support of sails.sockets.subscribers() for a multiple sails.js instance solution, I can't keep track of my connected workers very easily without falling back to tracking that via the db which is "slower" and is what I'm trying to avoid. I need to emit events to specific workers, connected to specific room ID's instead of just blasting to a room full of workers. Thanks and sorry for double posting, but I thought more insight would help clarify this use case. |
Ok, after looking into this quite a bit, and with help from @Oldwo1f, I can confirm that there's an issue with In the meantime, remember that you always have access to the low-level |
Just wanted to point out that in addition to Of course, Also, thanks for looking into this, I can imagine that it is a quite complex problem to solve with lots of moving parts. |
@bberry6 exactly--you can use rooms to get around almost any problem. If you look at socket.io-adapter, which defines the interface that |
@sgress454 Should that information be documented on the sails.sockets.* reference section of the sailsjs.org site? |
Ok, pushed some updates to sails and sails-hook-sockets that address this problem by setting up a message bus that all Sails apps subscribe to, and having the pubsub If you'd like to try this out, you'll need to use the master branch of Sails and make sure you
Then in one tab do:
and in the other tab you should see both @Oldwo1f has a pre-made testing environment for this here.
or
and listen for those messages using |
@sgress454 I doesnt work for me.
Are you sure this work for you? |
@Oldwo1f You need to install Sails from the master branch on Github. Do:
on each app. |
Ok it works for me too. for the sample case at least. now i ll update sails in my apps and see if it works Thanks for fixing this |
[comment moved to #3014] |
@sgress454 Hi Sgress I would like to let you know thats all is working fine for me now.Also I would like to mention that (because we disscuss about it before): I dont need a socket request to update model in order to let other socket subscribe know about modification. I simple http req works great as long as you use publishUpdate(). |
Definitely need to do this-- for both To start with, we need to verify:
I'm going to open a new issue that points back here from sails-hook-sockets as a way to track the documentation efforts. |
…oduce" and "retire" refs balderdashy#3008
Hello fellow devs!
Similar issues that have been open are #2593 and #849. I am running sails version 0.11.0.
Using socket.io-redis to handle communication between websockets connected to different sails instances is limited to
sails.sockets.blast
andsails.sockets.broadcast
. Usingsails.sockets.emit(externalSocketId, 'foo');
will not emit the eventfoo
to theexternalSocketId
.Additionally, running
sails.sockets.subscribers
with a room name that websocket connections from different sails instances have joined will only return the socket ids of the websocket connections that are connected to the instance of the requesting websocket.i.e.
lets say my socket id is
ab12
and I'm connected to an app on port 8000.another socket id
cd34
is connected to app on port 9000.They both join the room
foo
.Running
sails.sockets.subscribers('foo')
will only output['ab12']
instead of['ab12','cd34']
.I have created a simple test environment to show the issue.
For now, I will be using
sails.sockets.broadcast
as a work around, where I will broadcast messages to rooms that are the socket ids of the intended recipient.The text was updated successfully, but these errors were encountered: