Connect to a TCP server and exchange data. Supports auto-reconnect, configurable timeout, and bidirectional communication — send data via input and receive responses via output.
Overview
The tcp-client node connects to an external TCP server and enables bidirectional communication. Use it to:
- Communicate with PLCs - Modbus TCP, custom industrial protocols
- Connect to network devices - Routers, switches, custom hardware
- Stream data - Continuous data exchange with remote servers
- Command-response protocols - Send a command, receive a reply
This node is a client only — it connects to an existing server. Send data via the input port; received data comes out the output port. TCP provides reliable, ordered delivery with connection management.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
host | string | localhost | TCP server hostname or IP address to connect to. | |
port | number | 9000 | TCP server port number. | |
timeout | number | - | 10 | Connection timeout in seconds. |
autoReconnect | boolean | - | true | Automatically reconnect to server on disconnect. |
reconnectDelay | number | - | 5000 | Delay in milliseconds between reconnect attempts. |
Sending & Receiving
The node manages a persistent TCP connection to the server:
Any message received on the input port is sent to the connected TCP server.
msg.payload is written as-is (string or Buffer).
Data received from the server is emitted on the output port with
msg.payload containing the data.
Output Message Format
{
"payload": "data from server",
"_msgid": "<unique message id>"
} Auto Reconnect
When autoReconnect is enabled (default), the node automatically re-establishes the connection if it drops. The reconnectDelay property controls how long to wait between attempts (default: 5 seconds).
Connection Lifecycle
Connect → Exchange Data → Disconnect
↓
Wait reconnectDelay ms
↓
Reconnect Examples
Device Telemetry
Connect to a device over TCP and receive continuous telemetry readings.
TCP Telemetry Reader
Connects to a device's TCP endpoint and logs incoming telemetry to InfluxDB.
View Flow JSON
[
{
"id": "tcp1",
"type": "tcp-client",
"name": "Device Telemetry",
"host": "192.168.1.100",
"port": 9000,
"timeout": 10,
"autoReconnect": true,
"wires": [["function1"]]
},
{
"id": "function1",
"type": "function",
"name": "Parse",
"func": "const parts = msg.payload.split(',');\nif (parts.length >= 2) {\n msg.payload = { sensor: parts[0], value: parseFloat(parts[1]) };\n return msg;\n}\nreturn null;",
"wires": [["influx1"]]
},
{
"id": "influx1",
"type": "influxdb",
"name": "Store",
"measurement": "telemetry"
}
] Command & Response
Send periodic commands to a TCP server and process the responses.
Command & Response
Sends a query command every 5 seconds and processes the TCP response.
View Flow JSON
[
{
"id": "inject1",
"type": "inject",
"name": "Every 5s",
"repeat": "5",
"payload": "READ_STATUS\n",
"wires": [["tcp2"]]
},
{
"id": "tcp2",
"type": "tcp-client",
"name": "PLC",
"host": "192.168.1.50",
"port": 502,
"autoReconnect": true,
"wires": [["function2"]]
},
{
"id": "function2",
"type": "function",
"name": "Parse Response",
"func": "msg.payload = JSON.parse(msg.payload);\nreturn msg;",
"wires": [["debug1"]]
},
{
"id": "debug1",
"type": "debug",
"name": "Status"
}
] Troubleshooting
Cannot connect to server
- Verify the server is running and listening on the configured port
- Check firewall rules allow outbound connections on the port
- Test with netcat:
nc -v host port - Increase timeout if the server is slow to accept connections
Connection drops frequently
- Enable autoReconnect to automatically re-establish the connection
- Check for idle timeout settings on firewalls or load balancers
- Implement keepalive messages if the protocol supports it
- Monitor server logs for the reason connections are being closed
Data received but garbled
- TCP may split data across multiple packets — buffer until you see a delimiter
- Use a function node to accumulate data and split on newlines or fixed length
- Verify encoding matches between sender and receiver
- For binary protocols, check byte order (big-endian vs little-endian)