Overview
This node integrates with a NATS messaging system, allowing users to send requests and receive replies via the NATS protocol. It is useful in scenarios where asynchronous message-based communication is needed, such as microservices communication, event-driven architectures, or real-time data streaming.
The "Request" operation sends a message with a specified subject and payload to the NATS server and optionally waits for one or multiple replies. This can be used to query services, trigger remote actions, or exchange data between distributed components.
Practical examples:
- Sending a command to a microservice and waiting for its response.
- Querying a service registry or configuration service via NATS.
- Broadcasting a request and collecting multiple responses from different subscribers.
Properties
Name | Meaning |
---|---|
Subject | The NATS subject (topic) to which the request message will be sent. |
Payload Content Type | The type of the payload content: either a plain string or binary data stored in a specified property. |
Payload | The actual message payload as a string (used if Payload Content Type is "String"). |
Payload Binary Property Name | The name of the binary property containing the payload (used if Payload Content Type is "N8n Binary Data"). |
Headers | Optional key-value pairs to include as headers in the request message. |
Options | Additional options controlling request behavior: |
- Content Is Binary | Whether to save the received content as binary data. |
- JSON Parse Body | Whether to parse the response body as JSON. |
- Max Replies | Maximum number of replies to wait for from the service. |
- Only Content | Whether to return only the content property from the response. |
- Request Many | Whether to request multiple replies from services (enables multi-response mode). |
- Timeout | Maximum time to wait for incoming replies before timing out. |
Output
The node outputs an array of items corresponding to each input item processed. Each output item contains a json
field with the response data from the NATS service.
- If multiple replies are requested, the output may contain multiple response items per input.
- The content of the response can be raw or parsed JSON depending on the options.
- If the "Content Is Binary" option is enabled, the response content is saved as binary data.
- In case of errors during processing, the output includes error messages associated with the respective input item.
Dependencies
- Requires connection to a NATS server via a configured API authentication credential.
- Uses an internal NATS service client to manage connections and send/receive messages.
- No additional external dependencies beyond the NATS server and n8n credential setup.
Troubleshooting
Common issues:
- Connection failures due to incorrect or missing API credentials.
- Timeouts if no reply is received within the specified timeout period.
- Errors parsing response body if the content is not valid JSON but JSON parsing is enabled.
- Misconfiguration of subject or payload leading to unexpected responses or no replies.
Error messages:
- Errors thrown during request sending or receiving are reported per item.
- If "Continue On Fail" is disabled, the node execution stops on first error.
- To resolve errors, verify credentials, subject names, payload format, and network connectivity to the NATS server.