tcprequest

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

TCP Request node

Type: tcpRequest
Category: Network

Sends the payload over TCP and emits the server's reply.

Behavior

This node is registered as tcpRequest and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
delimiter string Delimiter — Reply terminator for delimiter mode (escape sequences like \n allowed)
errorCatch boolean false Error Catch Port — Adds a dedicated "error" output port; a node failure emits msg.error={text,node,full} on it when wired, else the catch/problem-queue ladder applies
host ``
keep boolean false Keep Connection — Reuse the client connection across messages instead of connect-send-close per message
length integer Length — Fixed reply size for length mode
mode string Reply Framing (legacy) — Legacy framing selector (timeout|delimiter|length); ignored when Close (out) is set
newline string Reply Delimiter — In sit mode with a string return, replies split on this delimiter (escape sequences like \n allowed)
out string Close — Node-RED reply selector: time = after a timeout of Splitc ms; char = after the Splitc character; count = after Splitc characters; sit = never close (stream replies); immed = immediately, don't wait
port integer Port — Remote port; the message's port metadata overrides it
ret string string Return Type — string: reply payload as text; buffer: raw bytes
server string Server — Remote host to connect to (Node-RED field name; host is the legacy alias)
splitc string Splitc — Node-RED close parameter for time/char/count: milliseconds, delimiter character or byte count
timeout number 10 Timeout (seconds) — Bounds connect + reply wait; 0 = 10 seconds
tls string TLS Config — Optional tlsConfig node; the connection is upgraded to TLS with that material
trim boolean false Re-attach Delimiter — Keep the delimiter attached to each reply part in sit mode

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

Documentation

Overview

Package tcprequest contains the tcpRequest node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCPRequestConfig

type TCPRequestConfig struct {
	// Server is the Node-RED host field ("" falls back to Host).
	Server string `json:"server"`
	// Host is the legacy host field (default 127.0.0.1).
	Host string `json:"host"`
	// Port is the remote port; message metadata "port" overrides it
	// (Node-RED msg.port semantics).
	Port int `json:"port"`
	// Ret selects the reply payload type: "string" (default) | "buffer"
	// (raw []byte). Node-RED field name: ret.
	Ret string `json:"ret"`
	// Out is the Node-RED close selector: "time" (reply after a
	// timeout of Splitc ms), "char" (reply ends at the Splitc
	// character), "count" (reply is exactly Splitc bytes), "sit"
	// (stay connected — stream replies) or "immed" (send and
	// close without waiting). "" falls back to the legacy Mode field.
	Out string `json:"out"`
	// Splitc is the Node-RED close parameter: milliseconds for
	// "time", the delimiter character for "char", the byte count for
	// "count". Serialized as a string by Node-RED.
	Splitc string `json:"splitc"`
	// Mode selects the reply framing: "timeout" (default — take
	// whatever arrives before Timeout), "delimiter" (read until the
	// delimiter bytes appear), "length" (read exactly Length bytes),
	// "sit" (stay connected, stream replies) or "immed" (don't wait
	// for a reply). The Node-RED Out field wins when set.
	Mode string `json:"mode"`
	// Timeout bounds connect + reply wait, in seconds (default 10;
	// 0 = 10). Out "time" overrides it with Splitc milliseconds.
	Timeout float64 `json:"timeout"`
	// Delimiter terminates the reply in "delimiter" mode
	// (escape sequences like \n allowed).
	Delimiter string `json:"delimiter"`
	// Length is the fixed reply size in "length" mode.
	Length int `json:"length"`
	// Newline delimits replies in "sit" mode when the return type is
	// string (escape sequences like \n allowed).
	Newline string `json:"newline"`
	// Trim re-attaches the delimiter to each reply part in "sit"
	// mode (Node-RED 're-attach' checkbox).
	Trim bool `json:"trim"`
	// Keep keeps the client connection open across messages instead of
	// closing it after each request/reply (Node-RED's persistent
	// client session). The connection is dropped on redeploy/stop.
	Keep bool `json:"keep"`
	// TLS names a tlsConfig node in the same workflow; when set the
	// connection is upgraded to TLS with that material.
	TLS string `json:"tls"`
}

TCPRequestConfig holds configuration for the tcpRequest node — the Node-RED `tcp request` equivalent: a client session that connects to a server, sends the payload and waits for the reply.

type TCPRequestNode

type TCPRequestNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

TCPRequestNode sends the payload over a TCP connection and emits the server's reply as the message payload.

func NewTCPRequestNode

func NewTCPRequestNode(node nodestore.NodeInterface, config *TCPRequestConfig, host nodebase.NodeHost) *TCPRequestNode

NewTCPRequestNode creates a new tcpRequest node

func (*TCPRequestNode) Execute

Execute dials (or reuses a kept connection), writes the payload and reads the reply per the configured framing.

func (*TCPRequestNode) Validate

func (n *TCPRequestNode) Validate() error

Validate checks the tcpRequest node configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL