Node.js client for a server


I have a server running and a matching webpage with a client. All works fine.

But, I am wondering if it is possible, on another machine, to run a separate node.js application which would act as a client and connect to the mentioned server?

5/22/2017 7:53:08 AM

Accepted Answer

That should be possible using Socket.IO-client:

5/22/2012 2:05:07 PM

Adding in example for solution given earlier. By using

Client Side:

var io = require('');
var socket = io.connect('http://localhost:3000', {reconnect: true});

// Add a connect listener
socket.on('connect', function (socket) {
socket.emit('CH01', 'me', 'test msg');

Server Side :

var app = require('express')();
var http = require('http').Server(app);
var io = require('')(http);

io.on('connection', function (socket){

  socket.on('CH01', function (from, msg) {
    console.log('MSG', from, ' saying ', msg);


http.listen(3000, function () {
  console.log('listening on *:3000');

Run :

Open 2 console and run node server.js and node client.js

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow