Hello,
I’m using the Milo package (0.1.5) to get data from a Siemens Sinumerik 840D SL numerical control, which comes with an OPC-UA server. In previous versions of
the server I had no problem with the default channel configuration, but in most recent versions of the server several exceptions arose in the publish response:
10/05/2017 08:47:19.267 ERROR [ua-shared-pool-1] org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler - Error decoding symmetric message:
max array length exceeded (length=310378496, max=65536)
org.eclipse.milo.opcua.stack.core.UaSerializationException: max array length exceeded (length=310378496, max=65536)
at org.eclipse.milo.opcua.stack.core.serialization.binary.BinaryDecoder.decodeArray(BinaryDecoder.java:422)
at org.eclipse.milo.opcua.stack.core.types.structured.PublishResponse.decode(PublishResponse.java:121)
at org.eclipse.milo.opcua.stack.core.serialization.binary.BinaryDecoder.decodeMessage(BinaryDecoder.java:388)
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.lambda$onSecureMessage$21(UaTcpClientMessageHandler.java:533)
at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$decode$1(SerializationQueue.java:58)
at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:107)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
It’s shocking the huge difference between the bytearray buffer size (65536) and the length received (310378496). I suspected there might be a bug in the server,
but another commercial client subscribe to server nodes without problems.
I tried to avoid the problem using a non-default ChannelConfig:
final int SIZE_FACTOR = 1024;
final int CHUNK_FACTOR = 16;
ChannelConfig channelConfig = new ChannelConfig(
ChannelConfig.DEFAULT_MAX_CHUNK_SIZE*SIZE_FACTOR,
ChannelConfig.DEFAULT_MAX_CHUNK_COUNT*CHUNK_FACTOR,
ChannelConfig.DEFAULT_MAX_CHUNK_COUNT*CHUNK_FACTOR * ChannelConfig.DEFAULT_MAX_CHUNK_SIZE*SIZE_FACTOR,
ChannelConfig.DEFAULT_MAX_ARRAY_LENGTH*SIZE_FACTOR,
ChannelConfig.DEFAULT_MAX_STRING_LENGTH*SIZE_FACTOR);
Then I normally avoid the exception (not always, despite the 1024 factor), but then other exceptions appear:
4975 [ua-shared-pool-0] ERROR org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler - Error decoding symmetric message: readerIndex(106) + length(1)
exceeds writerIndex(106): CompositeByteBuf(ridx: 106, widx: 106, cap: 106, components=1)
java.lang.IndexOutOfBoundsException: readerIndex(106) + length(1) exceeds writerIndex(106): CompositeByteBuf(ridx: 106, widx: 106, cap: 106, components=1)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1178)
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:587)
at io.netty.buffer.SwappedByteBuf.readByte(SwappedByteBuf.java:435)
at org.eclipse.milo.opcua.stack.core.serialization.binary.BinaryDecoder.decodeDiagnosticInfo(BinaryDecoder.java:356)
at org.eclipse.milo.opcua.stack.core.serialization.binary.BinaryDecoder.decodeArray(BinaryDecoder.java:428)
at org.eclipse.milo.opcua.stack.core.types.structured.PublishResponse.decode(PublishResponse.java:121)
at org.eclipse.milo.opcua.stack.core.serialization.binary.BinaryDecoder.decodeMessage(BinaryDecoder.java:388)
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.lambda$onSecureMessage$20(UaTcpClientMessageHandler.java:534)
at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$decode$1(SerializationQueue.java:58)
at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:107)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
At this point I don’t know what to do. Please find attached a full log of an attempt to subscribe to a single node of the server in case you find it useful (with
enlarged ChannelConfig). I can provide my code using milo if required, but as you probably don’t have that type of server available, I’d test any hack by myself.
Thanks in advance
Ignacio Garcia