P
P
PAJCH2020-01-24 23:40:19
JavaScript
PAJCH, 2020-01-24 23:40:19

SocketIO how to communicate between servers?

Good evening! Could you tell me (
For example, there is an Nginx balancer and several NodeJS servers on different hosts.
The SocketIO documentation says that in nginx, you need to use ip_hash to assign a cookie, and already in NodeJS you need to connect an adapter, so

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

But I have a question:
If I, as an example, at the office. I’ll specify the host site as local, then socketio will not know about other nodejs servers (
Then do I understand correctly that I need to create another server for Redis and specify the ip of this particular server in the host parameter?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question