Actions2
Listen
AI-generatedSummary
Connect to a specified WebSocket server URL and listen for incoming messages for a defined duration before closing the connection.
Inputs
- WebSocket URL (required) — The WebSocket server URL to connect to, starting with ws:// or wss://
- Listen Duration (ms) — How long (in milliseconds) to listen for messages from the server before closing the connection (default 30000 ms).
- Timeout (ms) — Connection timeout in milliseconds (default 30000 ms).
Output shape
a single JSON object containing the connection URL, operation type, an array of message objects (each with timestamp, type, and data), total number of messages captured, and count of received messages
The output includes all message types received during the listening period, such as connection openings, received messages, errors, and the connection close event. The listener automatically stops and resolves once the listen duration elapses, or sooner on connection close or errors.
Examples
Example 1: Listening to a WebSocket server
Set the WebSocket URL to your server endpoint and specify how long n8n should listen for messages by setting 'Listen Duration (ms)'. Optionally, adjust 'Timeout (ms)' for connection attempts. The node returns all messages received during the listen window.