Nodester.com home

03 3 / 2011

Running Websockets on Nodester!

Websockets are the latest craze and a natural fit for Node.JS.  Thanks to @DanBUK and @DavGlass, websockets are now supported on Nodester!

Deploying a websocket application to Nodester couldn’t be any easier.  We’ll use socket.io’s chat example as an example.  

All you need to make is two source code changes:

server.js
server.listen(8362);

chat.html
var socket = new io.Socket(null, {port: 80, rememberTransport: false}); 

Remember: The client side of the websocket always talks over HTTP port 80 on Nodester. The server side is the port that was assigned to you when you created your Nodester application.  You can always run the following CLI command to get the port addressed we assigned you (as the git repo and status):

nodester app info

Note: We actually just rolled out an enhancement where you no longer need to update your assigned port address.  We will automatically do it for you!

Now it’s time to deploy your hot new websocket-based Node.JS app on Nodester! Since Nodester applications are sandboxed, you will need to install your NPM module(s) with the following command:

nodester npm install socket.io

Node: You can install more than one module at once by adding a spaces between them such as nodester npm install socket.io express etc.

git push

That’s it!  If you need to restart your application for any reason, it’s as simple as:

nodester app restart

Now you’re ready to rock and roll with Nodester! Want to see this chat demo in action? Goto http://chat.nodester.com

Tags:

Permalink 12 notes