Implement reconnect after a connection-loss.
For longer running OPC-clients it is likely to happen that a connection-loss may occur during its runtime.
A connecton loss may happen because:
OPC-server stops/crashes and then restarts
network cable detached and then attached again either on OPC-server/OPC-client host machine
network interface deactivated and then reactivated either on OPC-server/OPC-client host machine
... and many more
In either of these cases a connection loss is the result and the OPC-client is no longer connected to the OPC-server. Therefore it would be great if this package then conducts all required operations in order to reestablish a connection to the OPC-server.
Some feature ideas for reconnect handling:
any OPC-subscriptions/monitored items that were present should be available also after the reconnect
some ideas/scenarios:
session at OPC-server is still available after reconnect
OPC-subscriptions are therefore still available on the OPC-server as the original session hasn't timed out. The client can rejoin the original session. Values of the monitored items were sampled during the connection loss and hence can be sent to the reconnected client
session is no longer available after reconnect
In this case a new session must be created during the reconnect and the OPC-subscriptions must be registered again.
some information can be queried if the original session was rejoined or a new session was created during reconnect
maybe add state Reconnected in enum CommunicationState
it would be also great to have an event hook that can also be consumed when the reconnect has completed
reconnect attempt can be canceled
e.g. because client application wants to shutdown
reconnect interval can be defined/given in codebase that uses this package
e.g. retry a reconnect every 30sec
Restoring subscriptions would be tricky because the client can create, modify and delete monitored items. The package would have to track a lot of info. We better leave this to the developer.
Implement reconnect after a connection-loss. For longer running OPC-clients it is likely to happen that a connection-loss may occur during its runtime. A connecton loss may happen because:
In either of these cases a connection loss is the result and the OPC-client is no longer connected to the OPC-server. Therefore it would be great if this package then conducts all required operations in order to reestablish a connection to the OPC-server.
Some feature ideas for reconnect handling:
any OPC-subscriptions/monitored items that were present should be available also after the reconnect some ideas/scenarios:
session at OPC-server is still available after reconnect OPC-subscriptions are therefore still available on the OPC-server as the original session hasn't timed out. The client can rejoin the original session. Values of the monitored items were sampled during the connection loss and hence can be sent to the reconnected client
session is no longer available after reconnect In this case a new session must be created during the reconnect and the OPC-subscriptions must be registered again.
some information can be queried if the original session was rejoined or a new session was created during reconnect
maybe add state
Reconnected
in enumCommunicationState
it would be also great to have an event hook that can also be consumed when the reconnect has completedreconnect attempt can be canceled e.g. because client application wants to shutdown
reconnect interval can be defined/given in codebase that uses this package e.g. retry a reconnect every 30sec