Skip to main content

TCP

Push

Synopsis

Creates a server that accepts network messages over TCP connections. Supports both plain and TLS-encrypted connections, with configurable framing modes, connection management, and buffering options.

Schema

- id: <numeric>
name: <string>
description: <string>
type: tcp
tags: <string[]>
pipelines: <pipeline[]>
status: <boolean>
properties:
protocol: <string>
address: <string>
port: <numeric>
framing: <string>
line_delimiter: <string>
max_connections: <numeric>
timeout: <numeric>
max_message_size: <numeric>
reuse: <boolean>
workers: <numeric>
buffer_size: <numeric>
batch_size: <numeric>
queue:
interval: <numeric>
tls:
status: <boolean>
cert_name: <string>
key_name: <string>

Configuration

The following are the minimum requirements to define the device.

Device

FieldRequiredDefaultDescription
idYUnique identifier
nameYDevice name
descriptionN-Optional description
typeYMust be tcp
statusNtrueEnable/disable the device

Network

FieldRequiredDefaultDescription
protocolN"tcp"Transport protocol (must be tcp)
addressN"0.0.0.0"Listen address
portYListen port

TCP

FieldRequiredDefaultDescription
framingN"delimiter"Framing mode (delimiter or octet)
line_delimiterN"\\n"Line separator for delimiter framing
max_connectionsN10000Maximum concurrent connections
timeoutN300Connection timeout in seconds
max_message_sizeN20971520Maximum message size in bytes (20MB)
warning

When using delimiter framing, ensure that the line_delimiter matches the client's to prevent message parsing errors.

TLS

FieldRequiredDefaultDescription
tls.statusNfalseEnable TLS encryption
tls.cert_nameYTLS certificate file path (required if TLS enabled)
tls.key_nameYTLS private key file path (required if TLS enabled)
note

The TLS certificate and key files must be placed in the service root directory.

Advanced Configuration

To enhance performance and achieve better message handling, the following settings are used.

Performance

FieldRequiredDefaultDescription
reuseNtrueEnable socket address reuse
workersN<dynamic>Number of worker processes when reuse is enabled
buffer_sizeN1048576Network read buffer size in bytes (1MB)

Messages

FieldRequiredDefaultDescription
batch_sizeN1000Number of messages to batch before processing
queue.intervalN1Queue processing interval in seconds

Examples

The following are commonly used configuration types.

Basic

A basic server can be easily created using "tcp" for protocol, "0.0.0.0" for address, and the default framing and timeout settings.

Creating a simple TCP server...

- id: 1
name: basic_tcp
type: tcp
properties:
port: 514

High-Volume

Performance can be enhanced using multiple workers, a larger buffer size (e.g. 4MB), a higher connection limit, and optimized batches.

Optimizing for high message volumes...

- id: 2
name: performant_tcp
type: tcp
properties:
port: 514
reuse: true
workers: 4
buffer_size: 4194304
max_connections: 20000
batch_size: 5000
queue:
interval: 2
note

The worker count is automatically capped at the number of physical cores available on the system.

Framing

A custom framing can be achieved using CRLF (i.e. "\r\n") as the message delimiter, a 5MB message size limit, and 1min connection timeout.

TCP server with custom message framing...

- id: 3
name: framed_tcp
type: tcp
properties:
port: 1514
framing: delimiter
line_delimiter: "\r\n"
max_message_size: 5242880
timeout: 60

Encryption

Security can be enhanced using TLS encryption, a custom certificate and key, connection limits, and an extended timeout the TLS handshake.

Securing TCP server with TLS encryption...

- id: 4
name: secure_tcp
type: tcp
properties:
port: 6514
tls:
status: true
cert_name: cert.pem
key_name: key.pem
max_connections: 5000
timeout: 120