2014-07-08 00:00:00 +0100 by Alex R. Young


Autobahn|JS (GitHub: tavendo / AutobahnJS, License: MIT, npm: autobahn) is an implementation of a protocol that supports RPC and PubSub that runs over WebSocket, with fallbacks for older browsers.

The PubSub model supports topics, and uses a promise-based API:

// Subscribe to a topic
session.subscribe('com.myapp.topic1', onEvent).then(
  function(subscription) {
    console.log('Subscribed:', subscription);
    currentSubscription = subscription;

  function(error) {
    console.error('Error:', error);

The support for RPC is based on a router, where routes are represented as strings. Registering a remote procedure also uses a promise:

// Define the remote procedure
function utcnow() {
  var now = new Date();
  return now.toISOString();

// Register the remote procedure with the router
session.register('com.timeservice.now', utcnow).then(
  function(registration) {
    console.log('Procedure registered:', registration.id);
  function(error) {
    console.error('Registration failed:', error);

You can call this remote procedure with session.call('com.timeservice.now'), which again returns a promise.

To use Autobahn, you also need an application router. The documentation mentions Crossbar.io. This allows you to create distributed server applications, so you could route between backends running on different platforms. Authorization is supported, so you can limit access to server-side resources.

The project is based on an open protocol called WAMP (Web Application Messaging Protocol). Other WAMP implementations include Autobahn|Android and wampy.js.