Creating web socket server on Azure hosting using Node.js?

I have a node application I am trying to host on Azure, that create a websocket server. I am trying to create the web socket server using the code below:

var socket = require('websocket').server;
...
server.listen(1111,function(){
   console.log('Http server is listening on port 1111');
});

When I do this on my local machine it works fine, but once it's up on Azure the following line of client side javascript:

var connection = new WebSocket('ws:' + document.domain + ':1111');
connection.send(msg); //throws error

Throws the error:

InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable

Can I get the desired functionality if I'm using azure? If so, any suggestions on where to start looking for a fix?

You can see the broken app in action here.

It will work on Azure, but you need to make a change. Try this:

server.listen(process.env.port, function () {
  var addr = app.address();
  console.log('Server listening on http://' + addr.address + ':' + addr.port);
});

Here's a tutorial on using the chat example from Socket.IO's source in Azure:

http://www.windowsazure.com/en-us/develop/nodejs/tutorials/app-using-socketio/

It assumes you're on Windows, which isn't strictly necessary. To use Node.js on Azure from a Mac or Linux system, just publish from Git:

http://www.windowsazure.com/en-us/develop/nodejs/common-tasks/publishing-with-git/