Socket.IO on subdomains with Express.js vhost

独自空忆成欢 提交于 2019-12-03 21:01:06
braitsch

The solution is to create one instance of Socket.IO in your root application that can be globally accessed by your subdomain applications and then run each app in its own Socket.IO namespace to preserve their autonomy.

I just built a simple example that runs three instances of a chat application all sharing the same instance of Socket.IO, which is declared in the root application.

If you clone the project and follow the instructions to set up the local subdomains you can see each instance of the chat application running independent of the others.

I will try to write up blog post with further details about how it works tomorrow morning.

Update

Here's a write up of how to share a Socket.IO instance across multiple domains.

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