net
net component: send msg to the specified protocol network server (does not support reading data), supports protocols: tcp, udp, ip4:1, ip6:ipv6-icmp, ip6:58, unix, unixgram, and other protocol types supported by the net package.
TIP
Each message will add an end character '\n' at the end of the content before sending
# Configuration
| Field | Type | Required | Description | Default value |
|---|---|---|---|---|
| protocol | string | Yes | Protocol tcp/udp, and other protocol types supported by the net package | tcp |
| server | string | Yes | Server address, in the format of host:port such as (:8888) | 0 |
| connectTimeout | int | No | Connection timeout(seconds). | 60 |
| heartbeatInterval | int | No | Heartbeat interval(seconds). Used to periodically send heartbeat messages. 0: don't send heartbeat messages | 60 |
| target | string | No | Addressing target. Only effective when server is ref:// mode. Supports ${} expressions (e.g. ${metadata.deviceId}); value is the sessionKey identifier (e.g. deviceId), * for broadcast. Exact match, no IP aggregation | - |
# Relation Type
- Success: Send successful, send the message to the
Successchain - Failure: Send failed, send the message to the
Failurechain
# Execution result
# Session Addressing Push (ref:// mode)
In addition to acting as a TCP/UDP client that dials and sends, the net component supports session addressing push: when server is set to ref://<endpoint/net instance ID>, it does not dial itself but reuses the long-lived device connections established by the server-side endpoint to actively push data to a specific device by target.
Use case: After a device connects to endpoint/net as a client and establishes a long connection, the business side uses the net node (ref:// mode) to deliver commands to specific devices, reusing the same connection without polling or extra connections.
Workflow:
- Device connects to
endpoint/netvia TCP/UDP, the first frame carries identity (e.g.deviceId) endpoint/netextracts the session key from the first frame viasessionKey(e.g.${msg.deviceId}) and registers it in the session poolnetnode withserver=ref://<endpoint/net>andtargetlooks up the connection from the session pool and pushes
target values:
- Concrete value (e.g.
DEV_001): precise addressing to a single device ${metadata.deviceId}: dynamically resolve target from message metadata*: broadcast to all connected devices- Empty (and not explicit
*): errors when the expression resolves to empty, no silent broadcast
{
"id": "s1",
"type": "net",
"name": "Send command",
"configuration": {
"server": "ref://net_endpoint_1",
"target": "${metadata.deviceId}"
}
}
2
3
4
5
6
7
8
9
TIP
ref://resolution order: same-chain endpoint first (defined in the current rule chainmetadata.endpoints) → shared poolNodePoolfallback. So an endpoint need not be placed innode_pool.json; defined inside the rule chain, it can also be referenced by same-chainnetnodes. See Component Connection Reuse- Addressing is exact match
target == sessionKey(*/empty for broadcast);targetshould be the value extracted bysessionKey(e.g. deviceId) - Heartbeat/reconnection of the outbound dial mode (
server=host:port) does not apply in ref:// mode (not an outbound connection)
# Configuration example
{
"id": "s1",
"type": "net",
"name": "Push data",
"configuration": {
"protocol": "tcp",
"server": "127.0.0.1:8888"
}
}
2
3
4
5
6
7
8
9
# Application example
Example reference: Example (opens new window)