TCP Testing Task
The
TCP Testing Taskdefines a TCP protocol testing task for functional, performance, stability, and custom testing of TCP.
Main Parameter List
| Field Name | Type | Required | Length/Range | Default | Description |
|---|---|---|---|---|---|
target | enum | Yes | - | TCP | Task Type Identifier Fixed value: TCP |
name | string | Yes | ≤400 chars | - | Task Unique Identifier Example: Device Heartbeat Detection |
description | string | No | ≤800 chars | - | Task Description Detailed explanation of communication purpose |
enabled | boolean | Yes | - | true | Enable Statustrue: Execute taskfalse: Skip task |
beforeName | string | No | ≤400 chars | - | Preceding Task Controls execution order Example: Data Preparation Task |
server | object | Yes | - | - | Server Configuration Includes host address and port information |
data | string | Yes | ≤2MB | - | Data to Send Supports raw content or Base64 encoding Supports variables and functions Example: @Hex('A0 01 FF') |
dataEncoding | enum | No | - | none | Data Encodingnone: Raw database64: Base64 encodedgzip_base64: Gzipped then Base64 encoded |
setting | object | Yes | - | - | Connection Settings Includes timeout, buffer, retry, and other parameters |
Note
Multiple SMTP interfaces can be orchestrated simultaneously, but only one SMTP can be enabled for testing at a time.
Complete TCP Configuration Example:
yaml
- target: TCP
name: Send tcp plain data
description: Using tcp protocol to send plain data to server
enabled: true
server:
# Server configuration ...
data: "This is a tcp data content"
dataEncoding: none
setting:
# Request settings ...Server Configuration (server)
| Field Name | Type | Required | Length/Range | Default | Description |
|---|---|---|---|---|---|
server | string | Yes | ≤253 chars | - | Server Address Supports IPv4/IPv6 addresses or domains Example: device-gateway.example.com |
port | integer | Yes | 1-65535 | - | Service Port Standard port range Example: 502 (Modbus) |
connectTimeout | string | No | 1s-24h | 6s | Connection Establishment Timeout Format: number + unit (e.g., 10s)Cross-region connections recommend 15-30s |
responseTimeout | string | No | 1s-24h | 60s | Response Wait Timeout Format: number + unit (e.g., 30s)Large data transfers recommend 120-300s |
Server Configuration Example:
yaml
server:
server: localhost
port: 8083
connectTimeout: 6s
responseTimeout: 60sRequest Settings (setting)
| Field Name | Type | Required | Length/Range | Default | Description |
|---|---|---|---|---|---|
tcpClientImplClass | enum | Yes | - | - | TCP Client Implementation ClassTcpClientImpl: Standard text protocolBinaryTcpClientImpl: Raw binary protocolLengthPrefixedBinaryTcpClientImpl: Binary protocol with length prefix |
reUseConnection | boolean | No | - | true | Connection Reusetrue: Keep connection for reusefalse: Create new connection each timeRecommended for high-frequency requests |
closeConnection | boolean | No | - | false | Close Connection Immediatelytrue: Close after sendingfalse: Keep connection openMutually exclusive with reUseConnection |
soLinger | integer | No | 0-65535 | - | Close Delay Time (seconds) Sets TCP connection's SO_LINGER option 0: Close immediately>0: Wait for specified seconds |
tcpNoDelay | boolean | No | - | true | Disable Nagle's Algorithmtrue: Disable to reduce latencyfalse: Enable to improve throughputRecommended for real-time systems |
tcpCharset | string | No | ≤16 chars | UTF-8 | Character Encoding Supports standard charset names Examples: GBK, ISO-8859-1, UTF-16 |
eolByte | byte | No | 0-255 | - | End-of-Line Byte Used for line separators in text protocols Example: 10 (\n) |
eomByte | byte | No | 0-255 | - | End-of-Message Byte Used for message termination Example: 13 (\r) |
binaryPrefixLength | integer | No | 2 or 4 | - | Length Prefix Bytes Message length prefix for binary protocols 2: 2 bytes (65535 bytes)4: 4 bytes (4GB) |
Request Settings Example:
yaml
setting:
tcpClientImplClass: TcpClientImpl
reUseConnection: true
closeConnection: false
soLinger: 100000
tcpNoDelay: true
tcpCharset: UTF-8
eolByte: 10
eomByte: 13
binaryPrefixLength: 2Client Implementation Classes (tcpClientImplClass)
1. TcpClientImpl (Text Protocol Implementation)
Core Features:
- Suitable for line-based text protocols (e.g., Telnet, SMTP)
- Uses
eolByteparameter to define line terminator (e.g.,\n=10) - Reads entire connection stream if
eolByteis not set - Typical applications: Command-line interfaces, log collection
Enterprise Configuration:
yaml
tcpClientImplClass: "TcpClientImpl"
eolByte: 10 # \n newline2. BinaryTcpClientImpl (Raw Binary Implementation)
Core Features:
- Suitable for unstructured binary protocols
- Uses
eomByteparameter to define message terminator (e.g.,0x03=ETX) - Reads entire connection stream if
eomByteis not set - Typical applications: Industrial control, device communication
Enterprise Configuration:
yaml
tcpClientImplClass: "BinaryTcpClientImpl"
eomByte: 3 # ETX terminator3. LengthPrefixedBinaryTcpClientImpl (Length-Prefixed Protocol Implementation)
Core Features:
- Suitable for binary protocols with length prefixes
- Specifies prefix length via
binaryPrefixLength(2 or 4 bytes) - Automatically parses length header and reads exact data amount
- Typical applications: Financial payments (ISO8583), large data transfers
Enterprise Configuration:
yaml
tcpClientImplClass: "LengthPrefixedBinaryTcpClientImpl"
binaryPrefixLength: 2 # 2-byte length prefixScript Examples (target)
Complete Parameter Configuration Example
yaml
- target: TCP
name: Send tcp plain data
description: Using tcp protocol to send plain data to server
enabled: true
server:
server: localhost
port: 8083
connectTimeout: 6s
responseTimeout: 60s
data: "This is a tcp data content"
dataEncoding: none
setting:
tcpClientImplClass: TcpClientImpl
reUseConnection: true
closeConnection: false
soLinger: 100000
tcpNoDelay: true
tcpCharset: UTF-8
eolByte: 10
eomByte: 13
binaryPrefixLength: 2Using TcpClientImpl to Send TCP Data
yaml
- target: TCP
name: Send tcp data using eol byte
description: Send TCP data using the TcpClientImpl class implementation.
enabled: true
server:
server: localhost
port: 8083
connectTimeout: 6s
responseTimeout: 60s
data: This is a tcp data content
dataEncoding: none
setting:
tcpClientImplClass: TcpClientImpl
reUseConnection: true
closeConnection: false
tcpNoDelay: true
tcpCharset: UTF-8
eolByte: 10Using BinaryTcpClientImpl to Send TCP Data
yaml
- target: TCP
name: Send tcp data using eom byte
description: Send TCP data using the BinaryTcpClientImpl class implementation.
enabled: true
server:
server: localhost
port: 8083
connectTimeout: 6s
responseTimeout: 60s
data: This is a tcp data content
dataEncoding: none
setting:
tcpClientImplClass: BinaryTcpClientImpl
reUseConnection: true
closeConnection: false
tcpNoDelay: true
tcpCharset: UTF-8
eomByte: 13Using LengthPrefixedBinaryTcpClientImpl to Send TCP Data
yaml
- target: TCP
name: Send tcp data using length prefixed
description: Send TCP data using the LengthPrefixedBinaryTcpClientImpl class implementation.
enabled: true
server:
server: localhost
port: 8083
connectTimeout: 6s
responseTimeout: 60s
data: This is a tcp data content
dataEncoding: none
setting:
tcpClientImplClass: LengthPrefixedBinaryTcpClientImpl
reUseConnection: true
closeConnection: false
tcpNoDelay: true
tcpCharset: UTF-8
binaryPrefixLength: 2