Dies ist der Code
Code: Select all
private final OpcUaClient client;
public MySubscriptionListener(OpcUaClient client) {
this.client = client;
}
public void onPublishFailure(UaSubscription subscription) {
// This is triggered when a publish cycle fails
logger.warn("Subscription publish failure: {}", subscription.getSubscriptionId());
}
public void onSubscriptionTransferFailed(UaSubscription subscription) {
// This is triggered when a subscription transfer fails (i.e., after a reconnect)
logger.error("Failed to transfer subscription {} after reconnection", subscription.getSubscriptionId());
client.connect();
// Resubscribe the nodes that failed to transfer
try {
createSubscription(client, subscription.getSubscriptionId().intValue());
} catch (Exception e) {
logger.error("Failed to recreate subscription after transfer failure", e);
}
}
Code: Select all
15:36:45.971 [milo-netty-event-loop-1] ERROR o.e.m.o.s.c.t.u.UascClientMessageHandler - [remote=KCT-L-610/192.168.41.223:53530] Exception caught: Connection reset
java.net.SocketException: Connection reset
at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:401)
at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:434)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:357)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:1583)
15:36:53.089 [milo-shared-thread-pool-12] WARN o.e.milo.opcua.sdk.client.SessionFsm - [2] Keep Alive failureCount=2 exceeds failuresAllowed=1```