我针对 KEPServerEX 5.2 版使用 Eclipse Milo Client SDK 0.2.2,但有时会失去连接。在我的日志中,我得到了这些堆栈跟踪:
ERROR 5048 --- [hared-pool-1693] o.e.m.o.s.c.h.UaTcpClientMessageHandler : Error decoding asymmetric message: expected sequence number 1140680 but received 1140681
org.eclipse.milo.opcua.stack.core.UaException: expected sequence number 1140680 but received 1140681
at org.eclipse.milo.opcua.stack.core.channel.ChunkDecoder$AbstractDecoder.decode(ChunkDecoder.java:166)
at org.eclipse.milo.opcua.stack.core.channel.ChunkDecoder.decode(ChunkDecoder.java:83)
at org.eclipse.milo.opcua.stack.core.channel.ChunkDecoder.decodeAsymmetric(ChunkDecoder.java:63)
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.lambda$onOpenSecureChannel$6(UaTcpClientMessageHandler.java:492)
at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$decode$1(SerializationQueue.java:64)
at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:107)
ERROR 5048 --- [hared-pool-1677] o.e.m.o.s.c.h.UaTcpClientMessageHandler : Error validating chunk headers: received unknown secure channel token: tokenId=57 currentTokenId=56 previousTokenId=55
org.eclipse.milo.opcua.stack.core.UaException: received unknown secure channel token: tokenId=57 currentTokenId=56 previousTokenId=55
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.validateChunkHeaders(UaTcpClientMessageHandler.java:704)
at org.eclipse.milo.opcua.stack.client.handlers.UaTcpClientMessageHandler.lambda$onSecureMessage$10(UaTcpClientMessageHandler.java:621)
at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$decode$1(SerializationQueue.java:64)
at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:107)
我的代码中有一个线程,通过每 5 分钟轮询服务器上的特定标签来保持会话永远打开。读取超时开始发生在令牌错误后一小时。我怀疑在令牌错误发生后我不允许更新/延长会话长度。之后,我无法再使用该会话了。
这是来自 OPC 服务器的预期行为吗?我应该处理它吗?
我知道我可以在我的保持会话打开线程中处理超时,也许断开连接并创建一个新会话,但是有没有更优雅的方法来做到这一点?