Example of how to run Socket.IO on multiple subdomains in the form of a simple chat server.

Project README

An example of how to share a single Socket.IO instance over multiple subdomains in the form of running three independent chat servers.


git clone git:// socket-io-example
cd socket-io-example

This project contains three separate applications, a root application ( that instantiates the Socket.IO instance and two subdomain applications that listen for incoming connections in their own namespace.

Note these applications can obviously be anything you like but for the purposes of this example they are just three instances of the exact same chat application running in three separate namespaces.

So to get these up and running, cd into each application and install its dependencies :

npm install
cd ../
npm install
cd ../
npm install
cd ../

Now open your /etc/hosts file in your editor of choice and add the following two subdomains so we can view them in a browser.

Somewhere after localhost and before broadcasthost add the following two lines : sub1.localhost sub2.localhost

Save and exit the file. Ensure you are inside of the directory and start the root application.

node app

Now point your browser at :


And you should have three isolated instances of the chat server running, all sharing the same Socket.IO instance.

Open Source Agenda is not affiliated with "" Project. README Source: braitsch/
Open Issues
Last Commit
5 months ago

Open Source Agenda Badge

Open Source Agenda Rating