Skip to content

Cant get it working with 'socket.io-redis' #30

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

Open
arashkay opened this issue Aug 17, 2016 · 3 comments
Open

Cant get it working with 'socket.io-redis' #30

arashkay opened this issue Aug 17, 2016 · 3 comments

Comments

@arashkay
Copy link

Hi @sibartlett ,

I'm using PM2 with -i max to run my app as cluster but the initial handshake fails. There is a solution which is http://socket.io/docs/using-multiple-nodes/ by using 'socket.io-redis'

var io = require('socket.io')(3000);
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));

Just tried to do something like this on server.register callback:

var io = server.plugins['hapi-io'].io;
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));

But didn't work. Any suggestion?

@throrin19
Copy link

I have the same problem, I use a cluster of hapi server and I need redis to redispatch to the corect server/client the events.

@barakyo
Copy link

barakyo commented Jan 29, 2018

Anyone able to get this working?

@drphelps
Copy link

drphelps commented Jun 3, 2018

You need to add the adapter to the plugin config, something like the this:

import HapiIO from 'hapi-io';
import ioRedis from 'socket.io-redis';
...
{
  register: HapiIO,
  options: {
    socketio: {
      adapter: ioRedis({
        host: process.env.REDIS_HOST,
        port: process.env.REDIS_PORT,
      }),
    },
  },
},
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants