Home

Awesome

CoAP Publish-Subscribe interface to RabbitMQ

Plug-in for the RabbitMQ broker implementing the Publish-Subscribe Broker for the Constrained Application Protocol (CoAP), which is designed for the Constrained RESTful Environments.

The REST architecture style promotes client-server operations on cacheable resources. This plug-in implements a REST API for the the Last Value Cache; a CoAP resource represents an information in the cache and (AMQP) messages represent updates of the cached information.

This is an experimental implementation of the draft-koster-core-coap-pubsub-02. Not for operational use.

The implementation is based on the Generic Erlang CoAP Client/Server. It supports the following features:

Interactions

Quick Introduction

RabbitMQ will listen for UDP packets on port 5683. You can use the command-line tool from libcoap, or any other CoAP client and perform all standard operations:

RabbitMQ Behaviour

Each CoAP topic is implemented as an RabbitMQ exchange. Subscription to a topic is implemented using a temporary RabbitMQ queue bound to that exchange.

Names of the temporary queues are composed from a prefix coap/ and IP:port of the subscriber. For example, a subscription from 127.0.0.1:40212 will be served by the queue coap/127.0.0.1:40212. Deleting this queue will forcibly terminate the observer.

All CoAP clients are authenticated as a user "anonymous". By setting RabbitMQ permissions for this user you can restrict access rights of the CoAP clients. The authenticated DTLS access is not supported (for now).

The message attributes gets converted as shown in the following table:

AMQPCoAP
message_id (<= 8 bytes)ETag
4 bytes of SHA(message_id)ETag (from AMQP)
expiration [milliseconds]Max-Age [seconds]
content_typeContent-Format

The implementation intentionally differs from the draft-02 in the following aspects:

Installation

This plug-in requires the Last value caching exchange. Please make sure that both rabbitmq_lvc and rabbitmq_coap_pubsub are installed.

RabbitMQ Configuration

To enable access via the plain CoAP (without authentication) you need to create the user "anonymous" with desired access rights.

To change the default settings you may add the rabbitmq_coap_pubsub section to your RabbitMQ Configuration.

<table> <tbody> <tr> <th>Key</th> <th>Documentation</th> </tr> <tr> <td><pre>prefix</pre></td> <td> Path to the pub/sub Function. The path is defined as a list of strings; each string defines one segment of the absolute path to the resource. <br/> Default: <pre>[<<"ps">>]</pre> </td> </tr> <tr> <td><pre>udp_listen</pre></td> <td> Port for incoming coap:// requests. <br/> Default: <pre>5683</pre> </td> </tr> <tr> <td><pre>dtls_listen</pre></td> <td> Port for incoming coaps:// requests. <br/> Disabled by default. </td> </tr> <tr> <td><pre>dtls_options</pre></td> <td> Configuration of the DTLS server. Shall include at least certfile and keyfile fields. See <a href="http://erlang.org/doc/man/ssl.html">ssl_option()</a> for more details. </td> </tr> </tbody> </table>

For example:

{rabbitmq_coap_pubsub, [
    {prefix, [<<"ps">>]},
    {udp_listen, 5683},
    {dtls_listen, 5684},
    {dtls_options, [
        {certfile, "/etc/rabbitmq/cert.pem"},
        {keyfile, "/etc/rabbitmq/key.pem"}
    ]}
]}

Installation from source

Build Status

Build and activate the RabbitMQ plug-in rabbitmq-coap-pubsub. See the Plugin Development Guide for more details.

$ git clone -b stable https://github.com/gotthardp/rabbitmq-coap-pubsub.git
$ cd rabbitmq-coap-pubsub
$ make dist

History

Copyright and Licensing

Copyright (c) 2015 Petr Gotthard petr.gotthard@centrum.cz. All Rights Reserved.

This package is subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.