Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Realtime server push with node.js, WebSockets and Comet
Pull request Compare This branch is 104 commits behind maccman:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


# Juggernaut

Juggernaut lets you push data to browser, which means you can do awesome 
things like multiplayer gaming, chat, realtime collaboration and more!

Juggernaut is super simple and easy to get going. 
Juggernaut 2, which is a completely rewrite, is built on node.js, is insanely fast, and can scale horizontally to millions of clients.

## Features
  * node.js server
  * Ruby client
  * Supports the following protocols:
    * WebSocket
    * Adobe Flash Socket
    * ActiveX HTMLFile (IE)
    * Server-Sent Events (Opera)
    * XHR with multipart encoding
    * XHR with long-polling
  * Reconnection support 

## Subscribe (JavaScript)

<script src="http://localhost:8080/application.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
  var jug = new Juggernaut;
  jug.subscribe("channel_name", function(data){
    console.log("Got data: " + data);

## Publish (Ruby)

Juggernaut.publish("channel_name", {:some => "data"})
Juggernaut.publish(["channel1", "channel2"], "foo")

## Requirements

 * Node.js
 * Redis
 * Ruby
node.js requirements:
 * node-static
 * redis-client
## Installation
 * Install node.js -
 * Install npm
   >> curl | sudo sh
 * Install
   >> sudo npm install
 * Install node-static
   >> sudo npm install
 * Install redis-client
   >> sudo npm install
 * Install Redis -
 * Install the Juggernaut gem (optional):
   >> sudo gem install juggernaut --pre

## Running

Start Redis
>> ./redis-server redis.conf

Download Juggernaut, and start the Juggernaut server:
>> git clone git://
>> cd juggernaut
>> node server.js

That's it! Now go to http://localhost:8080/ to see Juggernaut in action.

Start the server using root if you want Flash support. It needs to open a restricted port.

## Daemonize

# Scaling

Just create more Juggernaut daemons. Put a TCP load balancer in front of them.
Make sure they all connect to the same Redis instance. Use sticky sessions.

## Usage case - Group Chat

<script type="text/javascript" charset="utf-8">
  var jug = new Juggernaut;
  jug.subscribe("/chats", function(data){
    var li = $("<li />");

Juggernaut.publish("/chats", params[:body])

## Usage case - Private Chat

<script type="text/javascript" charset="utf-8">
  var jug = new Juggernaut;
  jug.subscribe("/chats/<%= %>", function(data){
    var li = $("<li />");

Juggernaut.publish( {|u| "/chats/#{}" }, params[:body])

## Usage case - Model Synchronisation 

# Implement sync_clients on models
  def sync_clients
# Check out client/examples/juggernaut_observer.rb and client/examples/juggernaut_observer.js
Something went wrong with that request. Please try again.