node package manager


Basic WebSockets Relay Server

Multiple clients can connect to this WebSockets server. Whenever a message is sent to the server by a client, every other client gets the message. Relay.


npm install -g wsrelay

Starting the Server

The default port used is 8124, although you can pass a port number as an argument.

wsrelay [port]

Connecting with wscat

You can test the server out using wscat, which is like the UNIX cat command but for websockets.

wscat --connect ws://localhost:8124

Be sure to connect two wscats to the server to see it relaying messages.

Writing your own client

Alternatively, you can write your own websocket client in Javascript

var WebSocket = require('ws');
var ws = new WebSocket('ws://localhost:8124');
//print out all relay messages received 
ws.onmessage = function(evt) {
  var message =;
//send all user input to the relay 
process.stdin.on('data', function(data) {