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

  • Home
  • SEARCH
  • 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 8604643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:37:28+00:00 2026-06-12T02:37:28+00:00

I created a express 3 app with the express generator and installed socket.io. On

  • 0

I created a express 3 app with the express generator and installed socket.io.
On app.js im emiting a message:

io.sockets.on('connection', function(socket) {
  socket.emit('init', { msg: 'Welcome'});
});

At server side I wrote:

<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src='/socket.io/socket.io.js' />
    <script>
        var socket = io.connect('http://127.0.0.1:3000');
        socket.on('init', function (data) {
            console.log(data.msg);
        });
    </script>
  </head>
  <body>
    <h1><%= title %></h1>
    <p>Welcome to <%= title %></p>
  </body>
</html>

If I run app.js It should print “Welcome” on the console, but its not priting anything. I checked if /socket.io/socket.io.js is accesed and it does.

When running the app I get:

  info  - socket.io started
Express server listening on port 3000
GET / 200 28ms - 472
GET /stylesheets/style.css 200 163ms - 110
   debug - served static content /socket.io.js

Am I missing something? I followed the socket.io webpage examples, but it seems that server is running fine… maybe something at the client-side?

EDIT: I also tried var socket = io.connect('http://127.0.0.1', { port: 3000 } ); on the client side, and also running all socket client side from the body.

Doing a console.log on the io.sockets.on event gave nothing… so “connection” is never reached.

  • 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-12T02:37:30+00:00Added an answer on June 12, 2026 at 2:37 am

    adding a index.jade file to the example I posted before

    server.js

    var app = require('express')()
      , http = require('http')
      , server = http.createServer(app)
      , io = require('socket.io').listen(server)
    
    server.listen(3000)
    io.set('loglevel',10) // set log level to get all debug messages
    io.on('connection',function(socket){
      socket.emit('init',{msg:"test"})
    })
    app.get('/',function(req,res){
      res.render('index.jade')
    })
    

    /views/index.jade

    doctype html
    html
      head
        script(src="/socket.io/socket.io.js")
        script.
          var sockets = io.connect()
          sockets.on('init',function(msg){
            alert(msg.msg)
          })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created an application in VS 2008 Express as an MFC app just to
I have created an Express 2.x app using the CLI. So I have a
I'm new to Node and Express. In the default app created by Express I
Windows. Node 0.8 express.js/express-resource // Configuration of Express Application for all environments app.configure(function(){ app.set('views',
In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); ... I have
I created a new ASP.NET website using Visual Web Developer 2008 Express edition and
I have a userform in 2008 vb express edition. A part number is created
I have installed VB.NET express 2010 version and I am trying to create a
I created a WPF application in Visual Studio 2010 Express (C#) and added the
I'm using the JavaScript Grid App template in Visual Studio Express 2012 to build

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.