Sails: Using socket.io-redis but there is nothing in my redis database

Created on 12 Apr 2016  路  6Comments  路  Source: balderdashy/sails

Sails version: 0.12.1
Node version: 4.2.4
NPM version: 3.5.2
Operating system: Windows 10


I have moved sockets to use socket.io-redis as opposed to memory because I need to deploy a Sails application (that is currently running in Windows) on Heroku. I have disabled "polling" and can see my clients all connecting with "websocket" so there should be no sticky session issues. My worry is that although everything seems to be working fine in a test environment, I cannot actually see any data in Redis that looks relevant to sockets. I admit I don't know what it might look like anyway, but I have other redis dependencies (busmq and redis-sessions) that are working fine and I can see the data in the database. Should I see evidence of socket.io-redis activity in the redis db? What would it look like? Perhaps I am just misunderstanding what happens under the covers.

Most helpful comment

Should I see evidence of socket.io-redis activity in the redis db? What would it look like? Perhaps I am just misunderstanding what happens under the covers.

I've been there-- it can be confusing at first. It's not actually _storing_ anything in Redis-- it's using Redis's built in message queuing to deliver messages. The actual room membership is stored in the memory of the individual Node processes-- this is why we had to implement an additional layer in Sails (used to be known as the "admin bus") in order to support .join() and .leave() in a multi-node environment (was part of the 0.12 release-- previously, join and leave would only work for a single Node server and not across the entire cluster).

Hope that helps! Sounds like you're doing everything right to me. 馃憤

All 6 comments

Hi @kpturner! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:

  • Verify "I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request). If you're not 100% certain whether it's a bug or not, that's okay--you may continue. The worst that can happen is that the issue will be closed and we'll point you in the right direction."

As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!

_If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]._

OK

Should I see evidence of socket.io-redis activity in the redis db? What would it look like? Perhaps I am just misunderstanding what happens under the covers.

I've been there-- it can be confusing at first. It's not actually _storing_ anything in Redis-- it's using Redis's built in message queuing to deliver messages. The actual room membership is stored in the memory of the individual Node processes-- this is why we had to implement an additional layer in Sails (used to be known as the "admin bus") in order to support .join() and .leave() in a multi-node environment (was part of the 0.12 release-- previously, join and leave would only work for a single Node server and not across the entire cluster).

Hope that helps! Sounds like you're doing everything right to me. 馃憤

Ok - many thanks for the clarification

I've been wondering this for the last couple days and trying to find it, so thanks for asking kpturner and for the clarification mikermcneil. I found it confusing too.

The config/sockets.js file says:

One of the big challenges of scaling an application is that these sorts
of clustered deployments cannot share memory

so I was expecting redis to be used for shared memory.

Just after that, it says:

However that means that all room/pubsub/socket processing and shared memory has to be offloaded to a shared, remote messaging queue (usually Redis)

The remote message queue part is key!

I'd recommend adding a statement like When working with sockets, Sails only needs Redis for the sake of its messaging queue. No data is stored in Redis., perhaps after the phrase "Luckily, Socket.io (and consequently Sails.js) apps support Redis for sockets by default."

@mikermcneil Can you confirm, does this mean that each server has a copy of ALL socket session data, even if it's only connected to a subset of those sockets?

I stumbled on to this issue cause I couldn't figure out why there was no data being saved in redis. Additional documentation would be very helpful.

@tylercollier Been wondering that myself as well. @mikermcneil Can you confirm tylers last question?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

radoslavpetranov picture radoslavpetranov  路  4Comments

victory-deployment picture victory-deployment  路  4Comments

alxndrsn picture alxndrsn  路  4Comments

anissen picture anissen  路  3Comments

MelwinKfr picture MelwinKfr  路  4Comments