Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

node.js and

node.js and


I have created a small Server for communication using node.js and socket io


var express = require('/usr/local/lib/node_modules/express')
var io = require('/usr/local/lib/node_modules/');
var server = express.createServer();
io = io.listen(server);
io.of("namespace").on('connection', function(client){
     client.emit("message",'connection successful');
     client.on('message', function(m){
        console.log("received message"+m);


    Comet Test

publish customAlert

publish customAl

Communication does not happen, am I doing something wrong here?

Problem courtesy of: user160108


If your server is listening on port 8888, you need the client to connect to the server on port 8888.

The following line in your client code:

var socket = io.connect('http://localhost/namespace');

Should read:

 var socket = io.connect('http://localhost:8888/namespace');
Solution courtesy of: fourk


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

node.js and


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription