Router

Akka Wamp provides you with a basic Router that can be either launched as standalone server process or embedded into your application. It implements:

  • WAMP Basic Profile,
  • Both broker and dealer roles,
  • JSON serialization,
  • WebSocket transport
Warning

Though perfectly functional, Akka Wamp Router is intended for development purposes only. You’re advised to adopt production ready WAMP routers such as Crossbar.IO

Standalone

Download

Download the latest version, extract, configure and run it as standalone application:

tgz
curl https://dl.bintray.com/angiolep/universal/akka-wamp-0.15.2.tgz
tar xvfz akka-wamp-0.15.2.tar.gz
cd akka-wamp-0.15.2
vim ./conf/application.conf
./bin/akka-wamp -Dakka.loglevel=DEBUG

Configuration

# akka.wamp.router {

# One or more endpoint configurations.
#
# Each endpoint configuration listed here will make the application
# bind a separate connection listener on the given address.
endpoint {
  local {
    # The address to bind to. Scheme can be:
    #
    #    - tcp
    #        Raw TCP
    #    - tsl
    #        Transport Secure Layer
    #    - ws
    #        WebSocket
    #    - wss
    #        WebSocket over TLS
    #
    address = "ws://localhost:8080/wamp"

    # Message format can be:
    #
    #    - json
    #        JSON Javascript Object Notation
    #
    #    - msgpack
    #        Message Pack
    #
    format = "json"
  }
  # Additional endpoint configurations here ...
  #
  # Each endpoint configuration will use the above "local"
  # configuration settings as fallback.
  #
  #  address = "wss://127.0.0.1:8443/wamp"
  #}
}
# The local filesystem path the router will serve static
# web resources (such as HTML docs) out of
#
webroot = ${user.home}/webroot

# The boolean switch to validate against strict URIs
# rather than loose URIs
#
validate-strict-uris = false

# The boolean switch to NOT automatically create realms
# if they don't exist yet.
#
abort-unknown-realms = false

# The boolean switch to drop offending messages (e.g.
# not deserializable or against the protocol).
#
# By default, offending messages will cause session to be
# closed and transport to be disconnected. Set this switch on
# if you rather prefer to drop offending messages and resume.
#
drop-offending-messages = false

Transports

An application can bind one or more listeners. Each listener corresponds to a named transport in the configuration file and it will bind to the configured endpoint. Usually, endpoints are configured for different schemes such as ws for WebSocket or wss for WebSocket with TLS - Transport Layer Security. Additional transport configuration falls back to the default one for missing keys (e.g. no need to repeat the format key)

Embedded

Create and bind an embedded router passing an actor reference factory (such as a brand new actor system or any of your actor context)

scala
/*
 * This file is subject to the terms and conditions defined in
 * file 'LICENSE.md', which is part of this source code package.
 */

import akka.actor._
import akka.wamp.router._

object LocalRouterApp extends App {
  val actorSystem = ActorSystem()
  EmbeddedRouter.createAndBind(actorSystem)
}

Internals

A Binder actor spawns a Router actor to be bound to the Akka IO Wamp Manager. The manager spawns one ConnectionListener actor which listens for incoming connection requests. The listener spawns a new ConnectionHandler actor upon each connection establishment to serve a specific client.

router