Trying out WebSocket with Node.js and Google Chrome in Ubuntu 9.10

Post to Twitter

I love the fact the latest Google Chrome builds (version 4.0+) now support WebSockets. Recently I did a post on using Node.js (getting up and running) and if you haven’t read that post you might want to do that before continuing.

[ad name=”Google Adsense”]

Update July 8, 2010 – Using the latest code for both Node.js and node.websocket.js there is an error produced. The author of node.websocket.js has two new projects though that are actively maintained (as of this writing) that do similar things:

With Ubuntu 9.10 you need to install Chrome. You can get Google’s Chrome browser from here:

Please keep in mind as of the date of this article that Google Chrome for Linux is still beta quality software so make sure you know what your doing before installing this.

The installation of Chrome for me was quick and problem free. In a few minutes I had Chrome up and running. If you haven’t used Chrome before your in for a treat because it is a very fast and capable browser with very good support for web developers.

With Chrome installed we turn our focus to getting an Guillermo Rauch’s excellent demo of using Node.js with WebSocket from github. Using GIT you can pull the source code from here:

git clone git://

Once you have all the code you can run the server with the default:

node runserver.js

This will default to running on localhost at port 8080. You can change the port if needed by doing the following:

node runserver.js --port='8888'

With the server up and running I simply dragged the “test.html” file out of the “node.websocket.js/test/websocket” folder and dropped it onto Chrome.

Next I took the “chat.html” file and dragged that into two instances of Chrome. From there I could run the chat program.

[ad name=”Google Adsense – large sqr rounded”]

Post to Twitter

This entry was posted in JavaScript, Node.js, Ubuntu. Bookmark the permalink.

3 Responses to Trying out WebSocket with Node.js and Google Chrome in Ubuntu 9.10

  1. Pingback: Messing around with Node.js and HTTP « Giant Flying Saucer

  2. Dan says:

    git clone git:// should be written with a lower case g.

    I tried your process and I get

    this.conn = new process.tcp.Connection();
    TypeError: Cannot read property ‘Connection’ of undefined
    at [object Object].connect (./node.websocket.js/lib/redis.js:47:32)
    at Object. (./node.websocket.js/log.js:66:8)
    at Module._compile (module:381:21)
    at Module._loadScriptSync (module:390:8)
    at Module.loadSync (module:296:10)
    at loadModule (module:241:16)
    at require (module:364:12)
    at Object. (./node.websocket.js/websocket.js:14:14)
    at Module._compile (module:381:21)
    at Module._loadScriptSync (module:390:8)

    Any idea what to do?

  3. Chad Lung says:


    Thanks for the tip on the “G”. I’ve updated the article now.

    I get the same error now as well with the latest Node.js. Looks like the issue though is in the websocket code. It appears that it hasn’t been updated on GitHub in a while – perhaps it got out of sync with changes to Node.js.

    It appears though he has two other projects actively maintained that should be capable of the same thing:


Comments are closed.