Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been having issues for a few days trying to set up a simple websocket server on an Amazon EC2 instance. I am using a micro instance of Linux. After booting up for the first time, I updated all OS packages, followed this great guide for getting node and npm installed, installed, express (not currently using), and which includes the websocket-server by miksago.

First, my attempts with as the backend. I set up a simple server using the sample code from their website, listed below. I run this with sudo node server.js. I use sudo so that I can listen on port 80, errors result otherwise. From here, I put my amazon public DNS into the location field at the echo test. When I press connect, my server will output debug - destroying upgrade. I have a console output within the "connection" listener that never gets printed, so it seems that there is an error before the connection request gets through. It may be that I have to use client side for a server to work, but I could not find any definitive answer on that.

My second attempt was using websocket-server by Miksago. I'll list the source for the server below as well. This time, I was able to see that console output on the connection request, but a connection was still not established. I tried printing the connection.header object but received an error.

I'm trying to set up a simple server just to get the basics going and I haven't been able to pin down what the issue is. I'm using to test the server since their client is set up correctly. What am I doing wrong setting up the server? server
var io = require('').listen(80);

io.sockets.on('connection', function (socket) {
  console.log("Connection request on server");

var ws = require("websocket-server");

var server = ws.createServer();

server.addListener("connection", function(connection){
  console.log("Connection request on Websocket-Server");


Edit: Debug output from node-websocket-server. This is a snippet of the output from console.log(connection._req); The information looks right, but the server is simply not establishing the connection.

httpVersion: '1.1',
complete: true,
 { upgrade: 'websocket',
   connection: 'Upgrade',
   host: '',
   origin: '',
   'sec-websocket-key': 'HdgJaiL2TZ4iyOHTarmlig==',
   'sec-websocket-version': '13' },
trailers: {},
readable: true,
url: '/',
method: 'GET',
statusCode: null,

Edit2: Use as a websocket server on Node.js. It works without needing client side js files, and is more up to date with spec. It is available through npm and git.

share|improve this question
Did you try the exact example code provided on the site? – ceejayoz Jan 3 '12 at 16:31
Yes, same debug error is printed. – brodney Jan 3 '12 at 16:47
For the client-side too? – ceejayoz Jan 3 '12 at 16:50
It appears that node-websocket-server may just be buggy. It hasn't been updated in a few months. A suggestion on the git page there pointed me to, the websocket server that is built on. I tried the sample code there and it worked with the echo test. – brodney Jan 4 '12 at 1:02
up vote 0 down vote accepted

According to this StackOverflow question, you must use's client-side code. Using's client-side code is going to give you this error.

share|improve this answer
That seems to be the case for the server. Do you have any idea why the miksago websocket server is also not establishing websocket connections? I'm updating the main question with some more debug output from that server. – brodney Jan 3 '12 at 21:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.