Skip to content

WebSocket Control PRO

Rebelle 8 Pro introduces WebSocket Control, allowing the software to be operated remotely via external devices, enabling exciting possibilities for interactive installations, live performances, projections, and custom hardware setups.

When starting Rebelle, use the following command line arguments:

  • -websocket-server-enable: Enable the WebSocket server. It is disabled by default.
  • -websocket-port PORT_NUMBER: Set the port number for the WebSocket server. The default is 8265.
  • -websocket-allowed-ip-addresses IP1,IP2,...: Comma-separated list of IP addresses allowed to connect to Rebelle's websocket server.
  • -websocket-allow-remote: Let devices other than this computer connect (since Rebelle 8.4). See Network access.
  • -websocket-allowed-path FOLDER: A folder in which SAVE, LOAD and EDIT_BRUSH_PRESET events may read and write files without asking (since Rebelle 8.4). Can be given more than once. See File access.

Then you can send any JSON event mentioned in the Rebelle Motion IO reference.

Network access

Since Rebelle 8.4, the WebSocket server listens on the local computer only (IPv4 address 127.0.0.1). Connect to ws://127.0.0.1:PORT_NUMBER rather than ws://localhost:PORT_NUMBER, because localhost may resolve to the IPv6 address ::1, where Rebelle does not listen.

The server accepts connections from other devices when you start Rebelle with -websocket-allow-remote, or when -websocket-allowed-ip-addresses lists at least one address other than 127.0.0.1. In that case only the listed addresses may connect (if the list is given). The server never accepts remote connections when Rebelle runs with -ui-automation.

Web pages

Since Rebelle 8.4, a web page that opens a WebSocket connection to Rebelle needs your approval, unless the page is served from this computer (localhost, 127.0.0.1 or ::1, any port). Rebelle recognizes such connections by the Origin that web browsers send; programs and scripts that send no Origin connect as before. Pages opened from a file (file://) also need approval.

Rebelle shows a question like "A web page at https://example.com (127.0.0.1) wants to control Rebelle over WebSocket. Allow this connection?". The default answer is No.

Rebelle asks once per web page origin: connections the same page opens while the question is open wait for the same answer.

  • Yes allows the waiting connections until they close. Rebelle then sends its greeting and processes the messages each of them sent while the question was open, in the order they were sent. Yes is not remembered: a connection the page opens later is asked about again.
  • No closes the waiting connections with close code 1008 (policy violation) and the reason "origin not allowed". The messages they sent are discarded. No is remembered until Rebelle is closed: later connections from the same origin are closed with 1008 at once, without a question.

While the question is open, a connection may send at most 256 messages or 16 MB. A connection that sends more is closed with close code 1009 (message too big) and the reason "too many messages before approval".

File access

SAVE and LOAD events can be sent over the WebSocket since Rebelle 8.3, also inside a GROUP. Since Rebelle 8.4, every filename in such an event, and the preset_path_in and preset_path_out of an EDIT_BRUSH_PRESET event, must be inside one of these locations:

  • a folder given with -websocket-allowed-path,
  • a folder you allowed for the current connection (see below).

Relative paths are resolved against the folder Rebelle was started in; that folder itself is not allowed unless you pass it with -websocket-allowed-path. Paths are checked after resolving .. and symbolic links, so a path cannot escape an allowed folder that way.

If an event uses a file outside these locations, Rebelle shows a question like "A WebSocket client (address) wants to save these files: ... Allow access to these folders for this connection?". The default answer is No.

  • Yes allows the folders containing those files for this connection until it closes, and the event runs.
  • No drops the event and Rebelle sends the client this reply:
{
    "event_type": "SAVE",
    "id": "my_save",
    "ok": false,
    "error": {
        "type": "file_access_denied",
        "paths": ["/home/user/other/result.png"],
        "message": "Rebelle denied access to: /home/user/other/result.png"
    }
}

event_type is the upper-case type of the top-level event (SAVE, LOAD, EDIT_BRUSH_PRESET or GROUP). The id is included only if the event had one. Later events are not affected. While the question is open, further messages from the same connection wait and are processed in the order they were sent after you answer. Other connections are not held back. If the connection closes before you answer, the waiting messages are discarded.

Allowed folders are not remembered: they are valid for one connection only. Folders must exist, because SAVE does not create folders.

Note

-websocket-allowed-path with an empty value is ignored.

REQUEST_FILE_ACCESS

A client can ask for access up front, so that later SAVE, LOAD and EDIT_BRUSH_PRESET events do not interrupt painting with questions:

{
    "event_type": "REQUEST_FILE_ACCESS",
    "id": "access1",
    "paths": ["/home/user/my_project", "/home/user/exports"]
}

Rebelle shows a question like "A WebSocket client (address) asks for access to save and load files in: ... Allow it for this connection?" (default No). Each listed folder or file, if allowed, gives access to itself and everything below it for this connection. If all paths are already allowed, no question is shown. Rebelle replies with:

{
    "event_type": "REQUEST_FILE_ACCESS",
    "id": "access1",
    "ok": true,
    "paths": ["/home/user/my_project", "/home/user/exports"]
}

ok is false when you answered No, when paths is missing, empty or not a list, or when an entry is not a valid path. id is included only if the request had one. REQUEST_FILE_ACCESS cannot be placed inside a GROUP: such a GROUP is refused as a whole with "ok": false and an error of type unsupported.

License

Note

Under the end-user license agreement, it is allowed to use the WebSocket Control feature for commercial purposes in the context of painting a still image, live performance, interactive installation, or real-time visual projection. You may also use the WebSocket Control feature to create non-commercial animations. However, if you intend to use WebSocket-controlled animations for commercial purposes, you must obtain a separate commercial license from Escape Motions. Please contact us at [email protected] for licensing inquiries.