Kanaloa is a simple framework for sending data between a JavaScript-enabled web client and an Erlang server.

Kanaloa supports streaming for most clients, with a fallback to "long polling" for the rest (Internet Explorer). These methods are used to implement "push" or "comet" connections, which imitate real bi-directional TCP sockets in JavaScript-enabled web browsers. Notably, these connections avoid the network overhead of repeated XMLHttpRequest polling, which is the traditional way to implement this functionality.

In streaming connections, the client initiates an HTTP request that is not closed by the server. HTTP chunks are continuously sent down to the client, which is able to receive them individually. In longpolling, the client also initiates a potentially long-running request to the server, but because the browser's XMLHttpRequest implentation does not support receiving the body incrementally, the server must close the connection as soon as data is available for the client.

Get Kanaloa

The project is hosted on GitHub and is released under the MIT license.

Kanaloa depends on the excellent mochiweb web server, also available on GitHub.


On the client side, the user creates a single instance of the KanaloaConnection class per service. Setting functions to the onConnectionOpened, onDataReceived, and onConnectionClosed properties will register callbacks to each of those events. The user can transmit arbitrary JavaScript objects to the server with the send method.

On the server side, each client connection is represented by an erlang process. The application using Kanaloa passes in a function to handle new connections. This function is called in a new process, and is responsible for handling messages sent by the Kanaloa framework. It communicates with the client through a parameterized module that wraps MochiwebHttpResponse.

You can generate some edocs from the source.


Erlang source on GitHub

Valid XHTML 1.0 Transitional Valid CSS!