Skip to main content

Nanomsg

The nanomsg node-type uses libnanomsg to exchange messages. It is similar to the zeromq node-type.

nanomsg is a socket library that provides several common communication patterns. It aims to make the networking layer fast, scalable, and easy to use. Implemented in C, it works on a wide range of operating systems with no further dependencies.

The nanomsg node-type only implements the publish-subscribe protocol provided by nanomsg.

Prerequisites

This node-type requires libnanomsg (>= 1.0.0).

Implementation

The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/nanomsg.cpp

Configuration

Format Object (object) or Format Name (string) (format_spec)
string or Array of strings

A single endpoint URI or list of URIs on which this node should listen for subscribers.

string or Array of strings

A single endpoint URI or list of URIs pointing to which this node should connect to as a subscriber.

object (Output configuration (sent out by VILLASnode))
object (Input configuration (received by VILLASnode))
vectorize
integer
Default: 1

This setting allows to send multiple samples in a single message to the destination nodes.

The value of this setting determines how many samples will be combined into one packet.

Array of Hook Object (object) or Hook Name (string) (hook_list)
builtin
boolean (Builtin hook functions)
Default: true

By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled.

{
  • "format": "villas.human",
  • "publish": "http://example.com",
  • "subscribe": "http://example.com",
  • "out": {
    },
  • "in": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true
}

Endpoints

The nanomsg supports several different transport mechanisms which are listed in the following table:

NameURI exampleDocumentation
In-process transportinproc://testnn_inproc(7)
Inter-process transportipc:///tmp/test.ipcnn_ipc(7)
TCP transporttcp://1.1.1.1:456nn_tcp(7)
WebSocket transportws://example.com:8080nn_ws(7)

Example

node/etc/examples/nodes/nanomsg.conf
nodes = {
nanomsg_node = {
type = "nanomsg"

out = {
endpoints = [
# TCP socket
"tcp://*:12000",

# Interprocess communication
"ipc:///tmp/test.ipc",

# Inprocess communication
"inproc://test"
]
}
in = {
endpoints = [
"tcp://127.0.0.1:12000",
"ipc:///tmp/test.ipc",
"inproc://test"
]
}
}
}