Websocket Reconnect - Trigger icon

Websocket Reconnect - Trigger

Connect to a WebSocket endpoint and trigger on incoming messages. Supports header/query auth, extra query parameters, periodic token refresh, and auto-reconnect.

Websocket Reconnect - Trigger

AI-generated

Summary

Connects to a WebSocket endpoint and emits events for connection opens, incoming messages, errors, and closes. Configure authentication and query parameters as needed; optional token refresh, reconnect, ping keepalive, and an initial message control connection behavior.

Inputs

  • WebSocket URL — Full WebSocket URL, including any static query parameters.
  • Authentication — Choose None, Header (Bearer / API Key), or Query Parameter. The latter two use the node’s corresponding credentials.
  • Extra Query Parameters — Optional name/value pairs appended to the URL on each connection; values are URL-encoded by the node.
  • Token Refresh — Optionally fetch a token before connecting, using either one endpoint or a two-step fetch-and-refresh flow. Set the response path(s), token query parameter name, and prefix. In direct mode, configure the URL, HTTP method, headers, and optional POST body. In two-step mode, configure the current-token endpoint and admin header, then the refresh endpoint. Scheduled refresh can reconnect at a chosen interval.
  • Reconnect and Keepalive — Automatic reconnect is enabled by default, with a 10-second delay and unlimited attempts (0). Optional ping keepalive sends pings after the configured period without an incoming message.
  • Initial Message — Optionally send the configured JSON or plain-text message immediately after connecting.
  • Return WS Resource — Include the raw WebSocket object in open and message event output when enabled.

Output shape

A stream of event items

Each item has an event field: open includes bearerToken and ws; message includes the parsed JSON message when valid, otherwise text (binary data remains binary), and ws; error includes message; close includes only the event. Token refresh also emits a tokenRefreshed event with bearerToken and interval fields. The ws field is null unless Return WS Resource is enabled. The trigger returns close and manual-trigger functions to n8n.

Links

Discussion