node-red-contrib-dyno-websocket 0.11.3

WebSocket with dynamic configuration that can be changed in runtime

npm install node-red-contrib-dyno-websocket

red-contrib-dyno-websocket

Dynamic WebSocket client node for Node-RED.

Install

npm install node-red-contrib-dyno-websocket

Node

  • Type: dyno-websocket
  • Inputs: 1
  • Outputs: 2 (data, control)

Configuration:

  • url: string, can be wss:// or ws:// schema
  • headers: object?: optional, http headers to send during upgrade
  • topic: string?: optional, given topic will be added to all outgoing msg
  • autoConnect: boolean?: when true, node attempts connection on deploy and relevant config updates

These are startup defaults and can be changed at runtime with commands.

Input Commands

Set msg.command to one of:

  • config-set: overwrite configuration of node. Configuration should be sent in msg.payload. If url or headers are sent while connected, connection will be re-opened with new settings. If disconnected and autoConnect is true, node will attempt to connect.
    • url: string
    • headers: object?
    • topic: string?
    • autoConnect: boolean?
  • config-get: return current configuration in msg.payload
  • config-reset: reset dynamic configuration to values set in node editor
  • counters: return current runtime counters in msg.payload
  • counters-reset: reset runtime counters and return updated values in msg.payload
  • connect
  • disconnect
  • reconnect

If msg.command is not set, msg.payload is sent to the socket:

  • Buffer/Uint8Array: sent as binary frame
  • object: sent as JSON serialized string
  • others: sent as String(payload)

Outputs

Data output (output 1):

  • binary frame: raw Buffer
  • non-binary frame: parsed as JSON with fallback to plain-text

Control output (output 2):

  • Success:

    { topic?, event: string, ok: true, payload: any, counters: object }
    
  • Failure:

    {
      topic?,
      event: string,
      ok: false,
      payload: { message: string, error: string, extra?: any },
      counters: object
    }
    

Persistence

Node state is stored in node context (config, state) and can be inspected on Context Data page.

Note: settings will be lost after node re-deployment if Node-RED contextStorage is not set. Make sure you have at least one storage enabled, memory for example:

  // add to settings.js in you node-red home folder
  contextStorage: {
    default: { module: "memory" },
  },

Node Info

Version: 0.11.3
Updated 3 days ago
License: MIT
Rating: not yet rated

Categories

Actions

Rate:

Downloads

90 in the last week

Nodes

  • dyno-websocket

Keywords

  • node-red
  • websocket
  • web-socket
  • dynamic
  • configuration
  • runtime

Maintainers