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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:22:22+00:00 2026-06-05T08:22:22+00:00

So I have this very basic socket.io setup that you have probably seen a

  • 0

So I have this very basic socket.io setup that you have probably seen a thousand times already.

Please not that here that the files are served via apache.

server (app.js)

var io = require('socket.io').listen(8080);

io.sockets.on('connection', function(socket){ 
    socket.emit('server ready', {msg: 'hi'}) ;

    socket.on('random event', function(data) {
        console.log('received');
    })
}); 

and client

$(document).ready(function() {
    var socket = io.connect('http://127.0.0.1:8080/projectname/server/');

    socket.on('server ready', function(data){ 
        console.log('server ready!'); 
    });

    socket.emit('random event', {hurr: 'durr'});
});

However, the only output I get is

 debug - websocket writing 5:::{"name":"server ready","args":[{"msg":"hi"}]}

in the node console and nothing in the client console. Which is wrong.

I have tried the basic example from the socket.io website and it shows exactly the same behaviour. It logs the emitted data in the node console but nothing else seems to happen.

Edit: Upon further investigation, visiting the site in Firefox creates a different output in the node console:

info  - handshake authorized 178702677759276313
   debug - setting request GET /socket.io/1/xhr-polling/178702677759276313?t=1339080239192
   debug - setting poll timeout
   debug - client authorized for 
   debug - clearing poll timeout
   debug - xhr-polling writing 1::
   debug - set close timeout for client 178702677759276313
   debug - xhr-polling received data packet �17�1::/stock/server/�66�5::/stock/server/:{"name":"random event","args":[{"hurr":"durr"}]}
   debug - setting request GET /socket.io/1/xhr-polling/178702677759276313?t=1339080239263
   debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing 5:::{"name":"server ready","args":[{"msg":"hi"}]}

This looks like the data emitted fromt he client actually reached the server. However, it didnt seem to solve the actual problem: the console.log lines and both the client and the server side arent executed. This output is from Firefox 5.0.1 where it seems to fall back to xhr.

Thanks a lot in advance!

  • 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-05T08:22:25+00:00Added an answer on June 5, 2026 at 8:22 am

    If your projectname is stock, then that’s your problem. Socket.IO is thinking you’re using a namespace. You can see this in the xhr-polling received data packet log line. console.log is never called since you’re not listening on that namespace on the server side.

    You should get rid of /projectname/server from your client connect address and reference the client side library properly so you don’t get a 404. Whether that’s an Apache proxy issue or fixing the script src in your header depends on your current setup. I can’t tell from the code you’ve provided.

    PS: Socket.io should serve the client library at http://127.0.0.1:8080/socket.io/socket.io.js, but you might run into a cross-domain origin policy issue by referencing that asset from a document served by your apache server at port 80. Quick fix could be to serve the client lib from your apache server, which is in the socket.io-client module dist folder.

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

Sidebar

Related Questions

This is a very basic question but wanted to confirm that if we have
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
I have this very weird issue that I cant really get why it's not
I have a very basic python script that does HTTP connection. import socket def
This could be very basic.. I have a class [Version(2), Caching(false)] class Sample {
I have a very basic question. Lets take this snippet: #include <stdio.h> void foo(void)
This fiddle shows a very basic version of the markup I have. I want
I have this very simple example that I am using to learn structs in
Perhaps this is a very basic question, please pardon me if it is ---
I have this very basic problem, >>> from django.core import serializers >>> serializers.serialize(json, {'a':1})

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.