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 7542971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:18:26+00:00 2026-05-30T08:18:26+00:00

So I have been trying to get this to work 2 days and I

  • 0

So I have been trying to get this to work 2 days and I am stuck. This is my first time configuring a server for rails that uses NodeJS+Socket IO. I am a noob with NGINX and Unicorn. Basically the NodeJS+SocketIO part of my app will push messages to users who are connected to my app. This is my nginx.conf

server{
    listen 80 default;
    root /home/deployer/saigon/public;
    try_files $uri/index.html $uri @unicorn;

    location /sockets {
        proxy_pass http://localhost:3210;
    }

    location @unicorn {
       proxy_pass http://localhost:3000;
    }
}

And in my production.rb, I have configured the url which the user will have to send message to/receive message from

SOCKET_IO_URL ='http://localhost:8080/sockets

Why 8080? I use Vagrant to forward 8080 -> 80

I tried accessing http://localhost:8080/sockets and I was able to get the socket welcome message. I looked at my NodeJS server log and it was receiving messages alright. However, when it comes to broadcasting….. it just does not do it. Has anyone ever gotten this kind of app to work with the set up I am trying to do? Should I just go with Apache + Unicorn ?

‘

  • 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-05-30T08:18:27+00:00Added an answer on May 30, 2026 at 8:18 am

    Updated Answer

    I have finally figured out a way to get this working. It’s not at all obvious, but when hosting socket.io on a subfolder, you do NOT use the subfolder in the connect statement. This is what I was doing before and the client was never receiving a response.

    Not Working

    <script src="/test/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost:8080/test/', {resource:'test/socket.io'});
      socket.on('news', function (data) {
        console.log(data);
        socket.emit('my other event', { my: 'data' });
      });
    </script>
    

    http://localhost:8080/test/ This is the part which is throwing things off. That creates a namespace for the local socket which the server side does not respect. So the client sends the message on the namespace ‘/test/’ but the server responses are going to an empty namepace ” so the client never gets the messages. The workaround it to simply remove the ‘/test/’ and make sure you are using the resource variable on the client and the server.

    Working!

    <script src="/test/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost:8080', {resource:'test/socket.io'});
      socket.on('news', function (data) {
        console.log(data);
        socket.emit('my other event', { my: 'data' });
      });
    </script>
    

    I hope this helps you get things working on your end.

    Original Answer

    It is not a problem with your setup, it is a problem of socket.io not wanting to work on sub folder. I would bet willing to be that if you dropped the /sockets your example would work fine. I ran into the exact same problem when using http-node-proxy trying to host socket.io connections on subfolders. There was a bug created a while ago, but it was closed out and never resolved.

    https://github.com/LearnBoost/socket.io-client/issues/185

    https://github.com/LearnBoost/socket.io/issues/320

    I am still looking for a solution as well, but I have a feeling I’m going to have to roll up my sleeves and dig into the code myself.

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

Sidebar

Related Questions

I have been trying to get this to work for about three solid days
I have been trying for days to get this code to work, but I
I have been trying to get this to work correctly and I think I
I have been trying to get this jsfiddle to work. So far without luck.
This is crazy, I have been trying for hours to get this to work.
I have been trying to days now to get this website completed ... however,
I have been trying to get a2billing to work for the past 4 days
So I have been trying for hours to get this to work and I
I've been trying to get this to work for days upon days and it
I have been trying for days to get my gitolite work with jenkins so

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.