Skip to main content

WebSocket

The websocket node type send and receives simulation data via binary WebSocket messages.

Prerequisites

This node-type requires libwebsockets (>= 2.3.0).

Implementation

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

Configuration

By default the villas node daemon listens on http.port for HTTP and WebSocket requests. This behavior can be disabled by setting http.enabled to false.

Format Object (object) or Format Name (string) (format_spec)
destinations
Array of strings <uri> [ items <uri > ]

During startup connect to those WebSocket servers as a client.

Each URI must use the following scheme:

protocol://host:port/nodename

It starts with a protocol which must be one of ws (unencrypted) or wss (SSL). The host name or IP address is separated by ://. The optional port number is separated by a colon :. The node name is separated by a slash /.

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.

object (Output configuration (sent out by VILLASnode))
{
  • "format": "villas.human",
  • "destinations": [],
  • "in": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true,
  • "out": {
    }
}

Example

node/etc/examples/nodes/websocket.conf
nodes = {
ws = {
type = "websocket"

destinations = [
"ws://someserver:8080/somenode"
]
}
}

http = {
port = 8080
ssl_cert = "/etc/ssl/certs/mycert.pem"
ssl_private_key= "/etc/ssl/private/mykey.pem"
}