I want the Client to reconnect to the Server if the server went down and up again. I can add an SessionActivityListener to the Client which gets notified on SessionInactive and the SessionActive if the Server is back online. However, when i get the SessionActive and try to resubscribe i get an "secure channel invalid" error message.
14:32:28.209 [ua-netty-event-loop-11] ERROR o.e.m.o.s.c.h.UaTcpClientAcknowledgeHandler - [remote=/127.0.0.1:53530] Received error message: ErrorMessage{error=StatusCode{name=Bad_SecureChannelIdInvalid, value=0x80220000, quality=bad}, reason=Bad_SecureChannelIdInvalid (code=0x80220000, description="The specified secure channel is no longer valid.")}
so what i'm currently doing is, disconnect the client and create a completely new client with the same subscriptions as the old client. but i guess thats pretty hacky. so the question is, is there a way to just update the "old" clients connection and subscriptions?
i'm currently testing with the prosys simulation server
greetings, Lukas
Once the client has successfully connected it will automatically reconnect any time the connection is broken. It will attempt to resume the old session or create a new session automatically if necessary, and try to transfer subscriptions if a new session was created. This is all handled for you.
Subscription transfer may fail or not be supported by the server, in which case you need to re-create the subscriptions yourself. You should add a SubscriptionListener
to the OpcUaSubscriptionManager
and implement the onSubscriptionTransferFailed
callback, which notifies you that transfer failed and you need to re-create this subscription yourself.