Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:01:42+00:00 2026-06-05T18:01:42+00:00

I have two Express.js apps running on my server. A plain vanilla app called

  • 0

I have two Express.js apps running on my server.

A plain vanilla app called “main-app” and another that uses Socket.IO called “socket-app”.

I have “main-app” running at “mydomain.com” & “socket-app” running on a subdomain at “socket.mydomain.com”

I am routing requests to the socket-app via Express’s built-in vhost middleware.

— inside main-app.js —

var express = require('express');
var app = module.exports = express.createServer();
app.use(express.vhost('socket.mydomain', require('./socket-app/app.js')));

app.listen(8080, function(){
  console.log("Express server listening on port %d in %s mode");
});

This works fine and I can see my socket-app running on port 8080 at socket.mydomain

However, there seems to be a problem with websockets timing out and not receiving the “upgrade” event when running a Socket.IO app through vhost as discussed here.

So my question is how can I pipe this “upgrade” event from my main-app to my socket-app so all connected sockets can hear when someone connects & disconnects?

I’ve tried emitting the “upgrade” event from within “main-app” but it doesn’t appear to be working.

app.on('upgrade', function(req, socket) {
    socket.emit('upgrade', app);    
});

What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:01:44+00:00Added an answer on June 5, 2026 at 6:01 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables (some so-called dictionaries, only about ~50 entries I presume) that
I have two processes that interface with one another over stdin and stdout. Suppose
I have two apps. which current run in two different ports. script1.js: var express
Here's my problem: I have an application which uses sql server express 2005, and
I have a c# winform application that uses SQL 2005 Express. The application creates
I have two XML files. The first XML has a bunch of nodes that
I have two richtextbox's that display stored procedures and its previous version. I would
I have two server named server1 and server2.both having diffrent Static ip address.I want
I have two Less files in the public/stylesheets . I am using Express.js to
I installed SQL Server 2005 express on two computers. I installed SQL Server Management

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.