{"action":"created","issue":{"url":"https://api.github.com/repos/Unitech/pm2/issues/1510","repository_url":"https://api.github.com/repos/Unitech/pm2","labels_url":"https://api.github.com/repos/Unitech/pm2/issues/1510/labels{/name}","comments_url":"https://api.github.com/repos/Unitech/pm2/issues/1510/comments","events_url":"https://api.github.com/repos/Unitech/pm2/issues/1510/events","html_url":"https://github.com/Unitech/pm2/issues/1510","id":99767356,"number":1510,"title":"How to make socket.io work well with pm2 when start more than one instance?","user":{"login":"node-rookie","id":7260662,"avatar_url":"https://avatars0.githubusercontent.com/u/7260662?v=4","gravatar_id":"","url":"https://api.github.com/users/node-rookie","html_url":"https://github.com/node-rookie","followers_url":"https://api.github.com/users/node-rookie/followers","following_url":"https://api.github.com/users/node-rookie/following{/other_user}","gists_url":"https://api.github.com/users/node-rookie/gists{/gist_id}","starred_url":"https://api.github.com/users/node-rookie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-rookie/subscriptions","organizations_url":"https://api.github.com/users/node-rookie/orgs","repos_url":"https://api.github.com/users/node-rookie/repos","events_url":"https://api.github.com/users/node-rookie/events{/privacy}","received_events_url":"https://api.github.com/users/node-rookie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2015-08-08T03:52:22Z","updated_at":"2018-02-13T09:46:58Z","closed_at":"2015-08-14T15:23:17Z","author_association":"NONE","body":""},"comment":{"url":"https://api.github.com/repos/Unitech/pm2/issues/comments/365209664","html_url":"https://github.com/Unitech/pm2/issues/1510#issuecomment-365209664","issue_url":"https://api.github.com/repos/Unitech/pm2/issues/1510","id":365209664,"user":{"login":"knoxcard","id":7561190,"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-02-13T09:46:58Z","updated_at":"2018-02-13T09:46:58Z","author_association":"NONE","body":"thank you @jshkurti!  I couldn't find your solution anywhere else on the web.\r\n\r\nHere is what my end code looks like...\r\n\r\n**SERVER**\r\n```\r\n  var http = require('http')\r\n  http.globalAgent.maxSockets = Infinity\r\n  app.server = http.Server(app)\r\n  app.server.listen(parseInt(app.nconf.get('app:port')) + (process.env.NODE_APP_INSTANCE ? parseInt(process.env.NODE_APP_INSTANCE) : 0), () => {\r\n    app.sio = require('socket.io').listen(app.server, {\r\n      transports: [\r\n        'websocket',\r\n        'polling',\r\n        'long-polling'\r\n      ]\r\n    })\r\n    app.sio.adapter(require('socket.io-redis')({\r\n      host: 'localhost',\r\n      port: 6379\r\n    }))\r\n    app.sio.use((socket, next) => {\r\n      app.sessionMiddleware(socket.request, socket.request.res, next)\r\n    })\r\n    app.sio.sockets.on('connection', socket => {\r\n      var room = 'room_' + (socket.request.session.user_id ? socket.request.session.user_id : socket.request.session.id)\r\n      socket.join(room)\r\n      app.sio.sockets.in(room).emit('auth', {\r\n        action: 'check'\r\n      })\r\n    })\r\n    app.sio.sockets.on('disconnect', () => {\r\n      console.log(app.colors.red('[socket disconnected]'))\r\n    })\r\n  })\r\n```\r\n**CLIENT**\r\n```\r\n\tjQuery.socket = io()\r\n\tjQuery.socket.on('connect', function() {\r\n\t\tjQuery.socket.on('auth', function(ret) {\r\n\t\t})\r\n\t})\r\n\tjQuery.socket.on('disconnect', function() {\r\n\t\tjQuery.reconnect = null\r\n\t\tjQuery.reconnect = setInterval(function() {\r\n\t\t\tjQuery.socket = io.connect()\r\n\t\t\tconsole.log('Attempting server connection...')\r\n\t\t}, 10000)\r\n\t})\r\n```\r\n"}}
{"actor":{"display_login":"knoxcard"}}