influxdata / influxdata/telegraf
[[inputs.opcua_listener]] Message too large when creating subscriptions with lots of nodes
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
### Relevant telegraf.conf
```toml
[[inputs.opcua_listener]]
## Metric name
name = "opcua"
#
## OPC UA Endpoint URL
endpoint = "opc.tcp://10.1.30.40:62541"
#
## Maximum time allowed to establish a connect to the endpoint.
# connect_timeout = "10s"
#
## Maximum time allowed for a request over the estabilished connection.
request_timeout = "10s"
#
## Security policy, one of "None", "Basic128Rsa15", "Basic256",
## "Basic256Sha256", or "auto"
security_policy = "Basic256Sha256"
#
## Security mode, one of "None", "Sign", "SignAndEncrypt", or "auto"
security_mode = "SignAndEncrypt"
#
## Path to cert.pem. Required when security mode or policy isn't "None".
## If cert path is not supplied, self-signed cert and key will be generated.
#certificate = "/etc/telegraf/public.pem"
certificate = "/etc/telegraf/opcua_client.crt"
#
## Path to private key.pem. Required when security mode or policy isn't "None".
## If key path is not supplied, self-signed cert and key will be generated.
#private_key = "/etc/telegraf/default_pk.pem"
private_key = "/etc/telegraf/opcua_client.key"
#
## Authentication Method, one of "Certificate", "UserName", or "Anonymous". To
## authenticate using a specific ID, select 'Certificate' or 'UserName'
auth_method = "UserName"
#
## Username. Required for auth_method = "UserName" # username = ""
username = "fakeusername"
## Password. Required for auth_method = "UserName"
password = "fakepassword"
client_trace = true
nodes = [
{name="AirValveFeedback", namespace="1", identifier_type="s", tags=[['position', '1'], ['io_type', 'input'], ['plc', '1'], ['source', 'flume'], ['signal', 'AirValveFeedback']], identifier="[Main Controller PLC 1]Machine[1].Inputs.AirValveFeedback"},
... 1000+
]
```
### Logs from Telegraf
```text
influx@ttt-influxdb-01:/etc/telegraf$ sudo telegraf --debug --config zone1.conf
2025-10-22T16:38:05Z I! Loading config: zone1.conf
2025-10-22T16:38:05Z I! Starting Telegraf 1.36.2 brought to you by InfluxData the makers of InfluxDB
2025-10-22T16:38:05Z I! Available plugins: 239 inputs, 9 aggregators, 35 processors, 26 parsers, 65 outputs, 6 secret-stores
2025-10-22T16:38:05Z I! Loaded inputs: opcua_listener
2025-10-22T16:38:05Z I! Loaded aggregators:
2025-10-22T16:38:05Z I! Loaded processors:
2025-10-22T16:38:05Z I! Loaded secretstores:
2025-10-22T16:38:05Z I! Loaded outputs: influxdb_v2
2025-10-22T16:38:05Z I! Tags enabled: host=ttt-influxdb-01
2025-10-22T16:38:05Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"ttt-influxdb-01", Flush Interval:10s
2025-10-22T16:38:05Z W! [agent] The default value of 'skip_processors_after_aggregators' will change to 'true' with Telegraf v1.40.0! If you need the current default behavior, please explicitly set the option to 'false'!
2025-10-22T16:38:05Z D! [agent] Initializing plugins
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Initialising OpcUAInputClient
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Initialising OpcUAClient
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Initialising node to metric mapping
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Creating monitored items
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Creating event streaming items
2025-10-22T16:38:05Z D! [agent] Connecting outputs
2025-10-22T16:38:05Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2025-10-22T16:38:05Z D! [agent] Successfully connected to outputs.influxdb_v2
2025-10-22T16:38:05Z D! [agent] Starting service inputs
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Connecting OPC UA Client to server
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:70 uacp: connecting to opc.tcp://10.1.30.40:62541
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:94 uacp 1: start HEL/ACK handshake
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:429 uacp 1: sent HELF with 58 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 1: recv ACKF with 28 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:271 uacp 1: recv &uacp.Acknowledge{Version:0x0, ReceiveBufSize:0xffff, SendBufSize:0xffff, MaxMessageSize:0x200000, MaxChunkCount:0x40}
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:576 sc.open
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 1
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 1/1: send *ua.OpenSecureChannelRequest with 132 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 1: recv OPNF with 135 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 1/1: recv OPNF with 135 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 1/1: recv *ua.OpenSecureChannelResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 1/1: sending *ua.OpenSecureChannelResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:660 OpenSecureChannelResponse handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:670 sc.handleOpenSecureChannelResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:698 uasc 1: received security token. channelID=2244 tokenID=2430 createdAt=2025-10-22T16:38:05Z lifetime=1h0m0s
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 2
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 1/2: send *ua.GetEndpointsRequest with 95 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:836 uasc 1: security token is refreshed at 2025-10-22T17:23:05Z (45m0s). channelID=2244 tokenID=2430
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:868 uasc 1: security token expires at 2025-10-22T17:53:05Z. channelID=2244 tokenID=2430
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 1: recv MSGF with 3290 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 1/2: recv MSGF with 3290 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 1/2: recv *ua.GetEndpointsResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 1/2: sending *ua.GetEndpointsResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1180 uasc 1: Close()
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 3
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 1/3: send *ua.CloseSecureChannelRequest with 57 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:221 uacp 1: close
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:329 uasc 1: readChunk EOF
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Configuring OPC UA connection options
2025-10-22T16:38:05Z D! [inputs.opcua_listener] opcua_util.go:226 Loading cert/key from /etc/telegraf/opcua_client.crt//etc/telegraf/opcua_client.key
2025-10-22T16:38:05Z D! [inputs.opcua_listener] security policy from configuration http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
2025-10-22T16:38:05Z D! [inputs.opcua_listener] User cares about both the policy (http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256) and security mode (MessageSecurityModeSignAndEncrypt)
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Server has 2 endpoints
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Evaluating endpoint opc.tcp://10.1.30.40:62541, policy http://opcfoundation.org/UA/SecurityPolicy#None, mode MessageSecurityModeNone, level 32
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Evaluating endpoint opc.tcp://10.1.30.40:62541, policy http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256, mode MessageSecurityModeSignAndEncrypt, level 136
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Security policy and mode found. Using server endpoint opc.tcp://10.1.30.40:62541 for security. Policy http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:70 uacp: connecting to opc.tcp://10.1.30.40:62541
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:94 uacp 2: start HEL/ACK handshake
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:429 uacp 2: sent HELF with 58 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv ACKF with 28 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:271 uacp 2: recv &uacp.Acknowledge{Version:0x0, ReceiveBufSize:0xffff, SendBufSize:0xffff, MaxMessageSize:0x200000, MaxChunkCount:0x40}
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:576 sc.open
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 1
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/1: send *ua.OpenSecureChannelRequest with 1454 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv OPNF with 1759 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:482 uasc 2: setting securityPolicy to http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 2/1: recv OPNF with 1759 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 2/1: recv *ua.OpenSecureChannelResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 2/1: sending *ua.OpenSecureChannelResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:660 OpenSecureChannelResponse handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:670 sc.handleOpenSecureChannelResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:698 uasc 2: received security token. channelID=2245 tokenID=2431 createdAt=2025-10-22T16:38:05Z lifetime=1h0m0s
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 2
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:836 uasc 2: security token is refreshed at 2025-10-22T17:23:05Z (45m0s). channelID=2245 tokenID=2431
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:868 uasc 2: security token expires at 2025-10-22T17:53:05Z. channelID=2245 tokenID=2431
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/2: send *ua.CreateSessionRequest with 1136 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv MSGF with 2416 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 2/2: recv MSGF with 2416 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 2/2: recv *ua.CreateSessionResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 2/2: sending *ua.CreateSessionResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 3
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/3: send *ua.ActivateSessionRequest with 816 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv MSGF with 144 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 2/3: recv MSGF with 144 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 2/3: recv *ua.ActivateSessionResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 2/3: sending *ua.ActivateSessionResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 4
debug: client: monitor: start
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/4: send *ua.ReadRequest with 176 bytes
debug: sub: pause
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv MSGF with 320 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 2/4: recv MSGF with 320 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 2/4: recv *ua.ReadResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 2/4: sending *ua.ReadResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Connected to OPC UA Server
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Creating OPC UA subscription
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 5
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/5: send *ua.CreateSubscriptionRequest with 160 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv MSGF with 112 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:350 uasc 2/5: recv MSGF with 112 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:289 uasc 2/5: recv *ua.CreateSubscriptionResponse
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:304 uasc 2/5: sending *ua.CreateSubscriptionResponse to handler
2025-10-22T16:38:05Z D! [inputs.opcua_listener] Subscribed with subscription ID 2021
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel_instance.go:89 got sequence number 6
debug: sub: pause: resume
debug: publish: pendingAcks=[]
debug: publish: PublishRequest: {"RequestHeader":null,"SubscriptionAcknowledgements":[]}
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1050 uasc 2/6: send *ua.CreateMonitoredItemsRequest with 65536 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:388 uacp 2: recv ERRF with 59 bytes
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:329 uasc 2: readChunk EOF
debug: client: monitor: disconnected
debug: client: monitor: auto-reconnecting
debug: client: monitor: action: createSecureChannel
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:221 uacp 2: close
2025-10-22T16:38:05Z D! [inputs.opcua_listener] secure_channel.go:1180 uasc 2: Close()
debug: client: monitor: trying to recreate secure channel
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:70 uacp: connecting to opc.tcp://10.1.30.40:62541
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:94 uacp 3: start HEL/ACK handshake
2025-10-22T16:38:05Z D! [inputs.opcua_listener] conn.go:429 uacp 3: sent HELF with 58 bytes
2025-10-22T16:38:05Z E! [telegraf] Error running agent: starting input inputs.opcua_listener: failed to start monitoring items: write tcp 10.1.30.81:55244->10.1.30.40:62541: use of closed network connection
```
### System info
Telegraf 1.36.2, Debian GNU/Linux 12
### Docker
_No response_
### Steps to reproduce
1. Create config with many nodes, 1000+
2. Run telegraf.conf
### Expected behavior
Expect the opcua_listener plugin to manange staying under the max message size and chunking it into message that stay under 65535 bytes.
### Actual behavior
Telegraf errors out with a failure to start the agent. The telgraf logs don't give much insight, however in our Igntion OPCUA server. The Igniton server has a log:
```
io.netty.handler.codec.DecoderException: UaException: status=Bad_TcpMessageTooLarge, message=max message length exceeded (65536 > 65535)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:500)
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:427)
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:394)
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1402)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:900)
at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:811)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.milo.opcua.stack.core.UaException: max message length exceeded (65536 > 65535)
at org.eclipse.milo.opcua.stack.core.channel.headers.HeaderDecoder.getMessageLength(HeaderDecoder.java:39)
at org.eclipse.milo.opcua.stack.server.transport.uasc.UascServerSymmetricHandler.decode(UascServerSymmetricHandler.java:83)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469)
... 18 common frames omitted
```
from the telegraf log I see `send *ua.CreateMonitoredItemsRequest with 65536 bytes` which matches the size from the Ignition log.
### Additional info
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.