Find file
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (61 sloc) 2.5 KB


You need to fetch the http-parser submodule, by typing:

git submodule init
git submodule update

Run demo

1 - run make clean all
2 - run ./river

3 - In a terminal, run:

curl -N -d "name=public-channel" ""

The call to /subscribe is blocking.

4 - And then, in another terminal:

curl -d "name=public-channel&data=hello-world-of-comet" ""

5 - The call to /subscribe returns, with the data published in the channel.

Embed in an HTML page

The following example considers the page to be at, and the comet server at

1 - Add a reference to the lib.js script in your page:

    <script type="text/javascript" src=""></script>

2 - Initialize the server:

    document.domain = "";

    function onMsg(msg) {
        alert("received message: ", msg);

    Comet.init(function() {
        var c = new Comet.Client();
        c.connect("public-channel", onMsg); // call onMsg upon reception of a message.

3 - The onMsg function will now receive all messages published on public-channel.


  • Parameters can be sent in GET or POST.
  • /subscribe takes 3 more (optional) parameters:
    • keep: Use HTTP streaming or close connection after every push (value=0 or 1, defaults to 1)
    • seq: Stream messages from a the sequence number up. Example: If 1000 messages have been sent, seq=990 will push 10 messages.
    • callback: function name for a JSONP callback.
  • The tests directory contains two benchmarking programs, websocket and bench. They can simulate large numbers of concurrent clients reading and writing messages. A single core can process more than 450,000 messages per second.

Chat Demo

A chat demo is available in the chat-demo directory. In order to use it, follow these steps:

  • Add the line to your /etc/hosts file.
  • Configure your web server to server the index.html file for On Apache2:
    <VirtualHost *:80>
    DocumentRoot /var/www/
  • Restart Apache.
  • Start river.
  • Open in your web browser.


  • Test support for Flash’s <policy-file-request>\0 in the WebSocket implementation.
  • More efficient channel deletion.
  • Remove dependency on dict.c in channels, use own HT.