loopback icon indicating copy to clipboard operation
loopback copied to clipboard

loopback with socket.io and socket.io-redis seems not really work on cluster

Open makersu opened this issue 11 years ago • 4 comments

By using socket.io-redis, but seems not really work. Do I need nginx/haproxy or anything more? Many thanks.

...
if (require.main === module) {
  app.io = require('socket.io')(app.start());
  var redis = require('socket.io-redis');
  app.io.adapter(redis({ host: 'localhost', port: 6379 }));
...

Or how do I use strong-cluster-socket.io-store after app.start()?

app.io = require('socket.io')(app.start());
???

makersu avatar Apr 08 '15 14:04 makersu

My solution: Set client socket.io transports to 'websocket'.

  var socket = io(ENV.BASE_URL, {
    transports: [ 'websocket' ]
  });

makersu avatar Apr 28 '15 06:04 makersu

:+1: same problem here @makersu

Didn't you end up with a server side solution?

behrad avatar Jun 09 '15 10:06 behrad

Define transport types on the client side: server:

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

client: index.html

<script src="lib/socket.io-client/socket.io.js"></script>

client: angular

function LBSocket($rootScope, ENV, User) {

...
  var socket = io(ENV.BASE_URL, {
    transports: [ 'websocket' ]
  });

Or maybe you can reference: https://github.com/btford/angular-socket-io

makersu avatar Jun 11 '15 11:06 makersu

Closing this issue as it has been resolved. If you are still running into problems, feel free to leave a comment and I will reopen the issue.

0candy avatar Aug 09 '16 21:08 0candy