With the default configuration, Sails allows realtime communication between a single server and all of its connected clients. When scaling your Sails app to multiple servers, some extra setup is necessary in order for realtime messages to be reliably delivered to clients regardless of which server they’re connected to. This setup typically involves:
socket.io-redisand setting the appropriate
password, etc. fields to point to your hosted Redis instance.
No special setup is necessary in your hosted Redis install; just plug the appropriate host address and credentials into your
/config/sockets.js file and the
socket.io-redis adapter will take care of everything for you.
Note: When operating in a multi-server environment, some socket methods without callbacks are volatile, meaning that they take an indeterminate amount of time to complete, even if the code appears to execute immediately. It's good to keep this in mind when considering code that would, for example, follow a call to
.addRoomMembersToRoom()immediately with a call to
.broadcast(). In such cases, the new room member probably won't receive the newly broadcasted message, since it is unlikely that the updated room membership had already been propagated to the other servers in the cluster when