Overview
This node sends data via the UDP (User Datagram Protocol) to a specified host and port. It is useful in scenarios where you need to transmit messages quickly and with low overhead, such as sending logs, metrics, or control signals to network devices or services that listen for UDP packets.
A practical example includes sending a custom message to a local or remote UDP server for monitoring or triggering actions. Optionally, the node can wait for a response from the server within a configurable timeout period, allowing it to be used in request-response UDP communication patterns.
Properties
Name | Meaning |
---|---|
Host | Target host address to which the UDP message will be sent (e.g., IP address or hostname). |
Port | Target port number on the host to send the UDP message to (1–65535). |
Message | The actual text message content to send over UDP. |
Options | Collection of additional options: |
Wait for Response | Whether to wait for a response from the UDP server after sending the message (true/false). |
Response Timeout | Time in milliseconds to wait for a response if enabled (100–30000 ms). |
Encoding | Text encoding used for the message and response. Options: UTF-8, ASCII, Base64, Hex. |
Output
The node outputs an array with one item per input, each containing a json
object describing the result of the UDP operation:
success
: Boolean indicating if the send operation was successful.protocol
: Always"udp"
.host
: The target host address.port
: The target port number.message
: The original message sent.encoding
: The encoding used for the message.status
: One of:"sent_no_wait"
— message sent without waiting for a response."no_response"
— waited for a response but none received before timeout."response_received"
— response received from the server.
bytes
: Number of bytes sent.timestamp
: ISO string timestamp when the operation completed.- If a response was received (
status === "response_received"
), includes:response.data
: The response message decoded using the specified encoding.response.bytes
: Number of bytes received.response.from
: Object withaddress
andport
of the sender.
The node does not output binary data directly; all messages and responses are handled as encoded strings.
Dependencies
- Uses Node.js built-in
dgram
module for UDP socket communication. - No external API keys or credentials are required.
- No special environment variables or n8n configurations needed beyond standard node setup.
Troubleshooting
- Common issues:
- Network unreachable or incorrect host/port may cause send errors.
- Firewall or network policies blocking UDP traffic.
- Waiting for a response when the server does not send any may lead to timeouts.
- Error messages:
UDP Send Error: <message>
indicates failure to send the UDP packet. Check host and port correctness and network connectivity.UDP Error: <message>
indicates an error occurred while listening for a response. This could be due to socket issues or network problems.
- To resolve errors, verify the target host and port are correct and reachable, ensure UDP traffic is allowed through firewalls, and adjust the response timeout as needed.