How to make sticky session works with socket.io (w/ or w/o pm2)?

百般思念 提交于 2019-12-01 20:11:20

问题


Although the socket.io document said 'sticky session' can make socket.io work with node cluster. I just can't make it work.

I find pm2 had several issues opened against it, the closest solution I can find is this, "force to use websock option only", don't use sticky session at all.

Has anyone had any experience that makes node cluster work with socket.io?

------- update --------

I checked the other two sticky session implementations mentioned here, sticky-session vs socket.io-sticky-session node js library ! Which is better? , find 'sticky-cluster' can do the job.

Another lesson I learned is that sticky-session doesn't work well with pm2 cluster, e.g. confirm from https://github.com/uqee/sticky-cluster/issues/26. So don't use pm2 cluster mode when using socket.io(or use 'websocket' transport only).

The 'sticky-session' implementation mentioned in socket.io document actually works too. If anyone needs more explanation with code sample, please check here https://github.com/elad/node-cluster-socket.io !

I leave my question open because I still like to see if there are other inputs.

来源:https://stackoverflow.com/questions/46891819/how-to-make-sticky-session-works-with-socket-io-w-or-w-o-pm2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!