diff --git a/index.js b/index.js index e867d238436f14d77448957e66ac7675784cc5e5..1cb039397b41db78ef075d1abb8eda5442ccacb0 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ const io = new Server(server, { cors: { origin: "*", methods: ["GET", "POST"], + transports: ['websocket', 'polling'], credentials: true } }); @@ -36,7 +37,7 @@ const redis = require('socket.io-redis'); const { createAdapter } = require('@socket.io/redis-adapter'); const { createClient } = require('redis'); -const pubClient = createClient({ host: '127.0.0.1', port: 6379 }); +const pubClient = createClient({ url: "redis://192.168.0.230:6379" }); const subClient = pubClient.duplicate(); io.adapter(createAdapter(pubClient, subClient)); @@ -236,7 +237,7 @@ async function addUserToActiveUsers(response, socket) { var userArr = Array.from(activeUsers.values()); //console.log(userArr); - io.emit('updateUserlist', { + socket.emit('updateUserlist', { userList : userArr }); }); @@ -264,7 +265,7 @@ async function deleteUserFromActiveUsers(response, socket) { clientActiveUsers.set(activeUsers.size); var userArr = Array.from(activeUsers.values()); - io.emit('updateUserlist', { + socket.emit('updateUserlist', { userList : userArr }); }); diff --git a/nginx/nginx.conf b/nginx/nginx.conf index cdcc278c675f7c6697ccc1ea04f1085a7545e7ef..514d39847a48d10c14915d65152d060ac7142fe0 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -26,7 +26,7 @@ http { upstream nodes { # enable sticky session with either "hash" (uses the complete IP address) - #hash $remote_addr consistent; + hash $remote_addr consistent; # least_conn; # or "ip_hash" (uses the first three octets of the client IPv4 address, or the entire IPv6 address) # ip_hash;