node-red-contrib-tcp-client-server-avd 1.2.0

Node-RED node voor TCP client en/of server functionaliteit

npm install node-red-contrib-tcp-client-server-avd

Node-RED TCP Client/Server Node (AVD)

Nederlands | English

Een flexibele Node-RED node die functioneert als TCP client en/of TCP server, met uitgebreide configuratiemogelijkheden en foutafhandeling.


Nederlands

Installatie

Via npm (aanbevolen)

npm install node-red-contrib-tcp-client-server-avd

Handmatige installatie

  1. Clone of download dit project
  2. Kopieer de map naar je Node-RED nodes directory (meestal ~/.node-red/nodes/)
  3. Installeer dependencies:
cd ~/.node-red/nodes/node-red-contrib-tcp-client-server-avd
npm install
  1. Herstart Node-RED

Functionaliteiten

TCP Client Mode

  • Automatisch verbinden bij flow start (optioneel)
  • Handmatig verbinden/verbreken via messages
  • Robuuste automatische herconnectie (detectie via error, close en write-fouten)
  • Snelle herverbinding (standaard 2 sec, minimum 1 sec)
  • Ondersteuning voor verschillende dataformaten (String, Buffer, JSON, Hex)
  • Message delimiter ondersteuning voor message framing
  • Keep-alive optie (aanbevolen voor detectie van half-open verbindingen)

TCP Server Mode

  • Automatisch starten bij flow start (optioneel)
  • Luisteren op geconfigureerde poort
  • Meerdere gelijktijdige client verbindingen
  • Unieke client identificatie
  • Broadcast naar alle clients of verzenden naar specifieke client
  • Zelfde dataformaat ondersteuning als client mode

Gecombineerde Mode

  • Gebruik zowel client als server functionaliteit in één node
  • Onafhankelijke configuratie voor beide modi

Gebruik

Basis Configuratie

  1. Sleep de node naar je flow
  2. Dubbelklik op de node om te configureren
  3. Selecteer de gewenste mode: TCP Client, TCP Server, of TCP Client & Server
  4. Configureer de instellingen volgens je behoeften

Client Mode - Verbinden

Automatisch verbinden:

  • Zet "Auto Verbinden" aan
  • De client verbindt automatisch bij flow start

Handmatig verbinden:

  • Zet "Auto Verbinden" uit
  • Stuur een message met topic: "connect" naar de node

Verbinden verbreken:

  • Stuur een message met topic: "disconnect" naar de node

Server Mode - Server Beheer

Automatisch starten:

  • Zet "Auto Start" aan
  • De server start automatisch bij flow start

Handmatig starten:

  • Zet "Auto Start" uit
  • Stuur een message met topic: "start" naar de node

Server stoppen:

  • Stuur een message met topic: "stop" naar de node

Message Formats

Input Messages (naar Node)

Client Mode:

Actie Message
Verbinden { topic: "connect" }
Verbreken { topic: "disconnect" }
Data verzenden { topic: "send", payload: "data" }

Als er geen topic is opgegeven, wordt de payload automatisch verzonden.

Server Mode:

Actie Message
Server starten { topic: "start" }
Server stoppen { topic: "stop" }
Naar client { topic: "send", clientId: "id", payload: "data" }
Broadcast { topic: "broadcast", payload: "data" }

Output Messages (van Node)

Client: topic: "status" (connected/disconnected/error), topic: "data" (ontvangen data)

Server: topic: "status", topic: "client/connected", topic: "client/disconnected", topic: "data" (met clientId)

ClientId bepalen (Server Mode)

De clientId is beschikbaar in client/connected en data messages. Gebruik clientId: msg.clientId in je send message.

Configuratie Opties

Client: Host, Port (8080), IP Versie, Auto Verbinden, Herconnectie, Reconnect Interval (2 sec), Connection Timeout (10 sec), Input/Output Format, Encoding, Message Delimiter, Keep-Alive

Server: Listen Port (8080), Bind Address (0.0.0.0), Auto Start, Max Connections, Connection Timeout (600 sec), Input/Output Format, Encoding, Message Delimiter, Keep-Alive

Status Weergave

Client: Groen (verbonden), Rood (fout), Grijs (niet verbonden), Geel (verbinden)

Server: Groen (luisterend), Rood (gestopt/fout), Blauw (actief met X clients)

Voorbeeld Flows

Importeer via Menu (≡) → Import → Examples:

  • Basis TCP Client – Client verbindt met localhost:8080
  • Basis TCP Server – Server luistert op 8080
  • Client-Server Echo – Server stuurt echo terug naar client

Troubleshooting

  • Client kan niet verbinden: Controleer server, firewall, host/port
  • Server kan niet starten: Controleer poort beschikbaarheid, firewall, rechten
  • Data onjuist: Controleer Output Format, Encoding, Delimiter

Bekende Beperkingen

  • TLS/SSL nog niet ondersteund
  • Alleen TCP (geen UDP)
  • Geen rate limiting

English

Nederlands | English

A flexible Node-RED node that acts as a TCP client and/or TCP server, with extensive configuration options and error handling.

Installation

Via npm (recommended)

npm install node-red-contrib-tcp-client-server-avd

Manual installation

  1. Clone or download this project
  2. Copy the folder to your Node-RED nodes directory (usually ~/.node-red/nodes/)
  3. Install dependencies:
cd ~/.node-red/nodes/node-red-contrib-tcp-client-server-avd
npm install
  1. Restart Node-RED

Features

TCP Client Mode

  • Auto connect on flow start (optional)
  • Manual connect/disconnect via messages
  • Robust automatic reconnection (detection via error, close and write failures)
  • Fast reconnection (default 2 sec, minimum 1 sec)
  • Support for various data formats (String, Buffer, JSON, Hex)
  • Message delimiter support for message framing
  • Keep-alive option (recommended for detecting half-open connections)

TCP Server Mode

  • Auto start on flow start (optional)
  • Listen on configured port
  • Multiple simultaneous client connections
  • Unique client identification
  • Broadcast to all clients or send to specific client
  • Same data format support as client mode

Combined Mode

  • Use both client and server functionality in one node
  • Independent configuration for both modes

Usage

Basic Configuration

  1. Drag the node to your flow
  2. Double-click the node to configure
  3. Select the desired mode: TCP Client, TCP Server, or TCP Client & Server
  4. Configure the settings according to your needs

Client Mode - Connecting

Auto connect:

  • Enable "Auto Verbinden" (Auto Connect)
  • The client connects automatically on flow start

Manual connect:

  • Disable "Auto Verbinden"
  • Send a message with topic: "connect" to the node

Disconnect:

  • Send a message with topic: "disconnect" to the node

Server Mode - Server Management

Auto start:

  • Enable "Auto Start"
  • The server starts automatically on flow start

Manual start:

  • Disable "Auto Start"
  • Send a message with topic: "start" to the node

Stop server:

  • Send a message with topic: "stop" to the node

Message Formats

Input Messages (to Node)

Client Mode:

Action Message
Connect { topic: "connect" }
Disconnect { topic: "disconnect" }
Send data { topic: "send", payload: "data" }

If no topic is specified, the payload is sent automatically.

Server Mode:

Action Message
Start server { topic: "start" }
Stop server { topic: "stop" }
To client { topic: "send", clientId: "id", payload: "data" }
Broadcast { topic: "broadcast", payload: "data" }

Output Messages (from Node)

Client: topic: "status" (connected/disconnected/error), topic: "data" (received data)

Server: topic: "status", topic: "client/connected", topic: "client/disconnected", topic: "data" (with clientId)

Determining ClientId (Server Mode)

The clientId is available in client/connected and data messages. Use clientId: msg.clientId in your send message.

Configuration Options

Client: Host, Port (8080), IP Version, Auto Connect, Reconnect, Reconnect Interval (2 sec), Connection Timeout (10 sec), Input/Output Format, Encoding, Message Delimiter, Keep-Alive

Server: Listen Port (8080), Bind Address (0.0.0.0), Auto Start, Max Connections, Connection Timeout (600 sec), Input/Output Format, Encoding, Message Delimiter, Keep-Alive

Status Display

Client: Green (connected), Red (error), Grey (disconnected), Yellow (connecting)

Server: Green (listening), Red (stopped/error), Blue (active with X clients)

Example Flows

Import via Menu (≡) → Import → Examples:

  • Basis TCP Client – Client connects to localhost:8080
  • Basis TCP Server – Server listens on 8080
  • Client-Server Echo – Server sends echo back to client

Troubleshooting

  • Client cannot connect: Check server, firewall, host/port
  • Server cannot start: Check port availability, firewall, permissions
  • Incorrect data: Check Output Format, Encoding, Delimiter

Known Limitations

  • TLS/SSL not yet supported
  • TCP only (no UDP)
  • No rate limiting

License

MIT

Version History

Version 1.2.0

  • Example flows: Basis TCP Client, Basis TCP Server, Client-Server Echo (via Import → Examples)
  • Bilingual README (Nederlands/English)

Version 1.1.0

  • Robust connection control: error handler triggers socket.destroy() for reliable reconnection
  • Write error detection: reconnection starts on failed send
  • Faster reconnection: default 2 sec, minimum 1 sec
  • No idle timeout after connect: connection stays open as long as both parties are connected
  • Prevention of double reconnect and race conditions

Version 1.0.0

  • Initial release
  • TCP Client functionality
  • TCP Server functionality
  • Combined mode
  • String, Buffer, JSON, and Hex data formats
  • Automatic reconnection
  • Message delimiter support

Support

For questions, issues or suggestions, open an issue on the GitHub repository.

Node Info

Version: 1.2.0
Updated 3 weeks ago
License: MIT
Rating: 5.0 1

Categories

Actions

Rate:

Downloads

185 in the last week

Nodes

  • tcp-client-server-avd

Keywords

  • node-red
  • tcp
  • client
  • server
  • socket

Maintainers