{"action":"created","issue":{"url":"https://api.github.com/repos/socketio/socket.io-redis/issues/282","repository_url":"https://api.github.com/repos/socketio/socket.io-redis","labels_url":"https://api.github.com/repos/socketio/socket.io-redis/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/socketio/socket.io-redis/issues/282/comments","events_url":"https://api.github.com/repos/socketio/socket.io-redis/issues/282/events","html_url":"https://github.com/socketio/socket.io-redis/issues/282","id":332706119,"node_id":"MDU6SXNzdWUzMzI3MDYxMTk=","number":282,"title":"Adapter seems to have no effect at all.","user":{"login":"vladikus10","id":9110189,"node_id":"MDQ6VXNlcjkxMTAxODk=","avatar_url":"https://avatars3.githubusercontent.com/u/9110189?v=4","gravatar_id":"","url":"https://api.github.com/users/vladikus10","html_url":"https://github.com/vladikus10","followers_url":"https://api.github.com/users/vladikus10/followers","following_url":"https://api.github.com/users/vladikus10/following{/other_user}","gists_url":"https://api.github.com/users/vladikus10/gists{/gist_id}","starred_url":"https://api.github.com/users/vladikus10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladikus10/subscriptions","organizations_url":"https://api.github.com/users/vladikus10/orgs","repos_url":"https://api.github.com/users/vladikus10/repos","events_url":"https://api.github.com/users/vladikus10/events{/privacy}","received_events_url":"https://api.github.com/users/vladikus10/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-15T09:29:11Z","updated_at":"2018-10-08T07:13:13Z","closed_at":null,"author_association":"NONE","body":"I'm building a NodeJS app which uses socket.io and being clustered. I'm trying to use socket.io-redis to bridge the processes. However, when I tried using socket.io-redis, it seemed to have not effect at all, when I tried with or without it, I still got the same results. \r\n\r\nI have declared the socket.io with socket.io-redis like so:\r\n```\r\nconst redisAdapter = require('socket.io-redis');\r\n\r\nmodule.exports.setup = (server) => {\r\n  io = require('socket.io')(server);  //server is a http server with an express app.\r\n\r\n  io.adapter(redisAdapter({ host: process.env.REDIS_HOST, port: process.env.REDIS_PORT }));\r\n\r\n  io.use((socket, next) => {\r\n    const token = socket.handshake.query.access_token;\r\n\r\n    if(!token) return next(ERRORS.SOCKET_MISSING_TOKEN);\r\n\r\n    jwt.verify(token).then(userData => {\r\n        socket.user = userData;\r\n        socket.id = userData._id;\r\n        next();\r\n    }, error => {\r\n        console.log(error);\r\n        next(ERRORS.FORBIDDEN);\r\n    });\r\n  });\r\n\r\n  io.on('connection', (socket) => {\r\n    console.log(`Socket connection: ${socket.id}`);\r\n    socket.authorized = false;\r\n\r\n    socket.on('disconnect', (reason) => {\r\n      console.log(`Socket disconnected: ${socket.id}`);\r\n    });\r\n\r\n    socket.on('error', (error) =>{\r\n      console.error(error);\r\n    });\r\n  });\r\n}; \r\n```\r\nAnd then I try to run a mocha test:\r\n```\r\n    it('Should send a new message', done => {\r\n        const message = {\r\n            recipient_id: user2._id,\r\n            message: 'Hello'\r\n        };\r\n\r\n        const io2 = io(`${global.url}?access_token=${user2.access_token}`);\r\n\r\n        io2.on(EVENTS.NEW_MESSAGE, receivedMessage => {\r\n\r\n            expect(receivedMessage.from).to.equal(user1._id);\r\n            expect(receivedMessage.to).to.equal(user2._id);\r\n            expect(receivedMessage.message).to.equal(message.message);\r\n\r\n            newMessage = receivedMessage;\r\n\r\n            done();\r\n        });\r\n\r\n        io2.on('connect', () => {\r\n            const io1 = io(`${global.url}?access_token=${user1.access_token}`);\r\n\r\n            io1.on('connect', () => {\r\n\r\n                io1.emit(EVENTS.SEND_MESSAGE, message);\r\n            });\r\n        });\r\n    });\r\n```\r\nIn the console I get this results:\r\n```\r\nSocket connection: 5b2384a7367e5079982e6c45\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a7367e5079982e6c45\r\nSocket connection: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\nSocket disconnected: 5b2384a74702f3799d268c9c\r\n```\r\nFor what ever reason it makes multiple connections and also the test timeouts after this (2 seconds timeout.) . As I mentioned before, I get the same results if I remove the adapter, as if it had no affect at all. \r\n\r\nWhen I try the same code and test with a single node process it gives the correct results:\r\n```\r\nSocket connection: 5b238489649adf795c56ea4d\r\nSocket connection: 5b238489649adf795c56ea4e\r\nSocket disconnected: 5b238489649adf795c56ea4e\r\nSocket disconnected: 5b238489649adf795c56ea4d\r\n```\r\nTwo users connected and two disconnected afterwards, and the test passed.\r\n\r\nMaybe I'm not doing it right? I'm pretty sure I registered the adapter the same way as the documentation says."},"comment":{"url":"https://api.github.com/repos/socketio/socket.io-redis/issues/comments/427739300","html_url":"https://github.com/socketio/socket.io-redis/issues/282#issuecomment-427739300","issue_url":"https://api.github.com/repos/socketio/socket.io-redis/issues/282","id":427739300,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzczOTMwMA==","user":{"login":"knoxcard","id":7561190,"node_id":"MDQ6VXNlcjc1NjExOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/7561190?v=4","gravatar_id":"","url":"https://api.github.com/users/knoxcard","html_url":"https://github.com/knoxcard","followers_url":"https://api.github.com/users/knoxcard/followers","following_url":"https://api.github.com/users/knoxcard/following{/other_user}","gists_url":"https://api.github.com/users/knoxcard/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxcard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxcard/subscriptions","organizations_url":"https://api.github.com/users/knoxcard/orgs","repos_url":"https://api.github.com/users/knoxcard/repos","events_url":"https://api.github.com/users/knoxcard/events{/privacy}","received_events_url":"https://api.github.com/users/knoxcard/received_events","type":"User","site_admin":false},"created_at":"2018-10-08T07:13:13Z","updated_at":"2018-10-08T07:13:13Z","author_association":"CONTRIBUTOR","body":"have you tried looking at the REDIS monitor?\r\n\r\n`redis-cli > monitor`"}}
{"actor":{"display_login":"knoxcard"}}