I am using socket.io with redis store. I have the following code taken as it is from socket.io website.
var io = require('socket.io')(server);
var redis = require('socket.io-redis');
io.adapter(redis({host: '128.199.122.183', port: 6379}));
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
Code runs as expected but I expected to see some entries (key value pairs) made in redis but didn't find any. Could anyone tell me how I can check if redis is being used by socket.io?
The current socket.io-redis package doesn't store anything in the database (though this might change in the future). It uses the redis pub/sub mechanism to distribute messages across different nodes.
To check if its working you need to start more than one instance of your app and then emit messages on one of them and check if all the others are receiving it.
You can also use redis-cli to see if its working.
redis-cli
>MONITOR
And then emit some messages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With