Repository navigation
How to properly implement the reconnection to the server #3097
Type of issue
Current BehaviorHello, I have several questions about reconnection mecanism : Doc about TransferSubscription :
In the sample, they use : I know sometimes the SDK send a new session with a different id from the previous one.
That the case in the sample, but it means that BeginReconnect will moves to that state on her own ?
Expected BehaviorNo response Steps To ReproduceNo response Environment- OS: Windows 11
- Environment: VS 2022
- Runtime: .Net 8
- Nuget Version: 1.5.376.213
- Component: /
- Server: /
- Client: my own implementationAnything else?Sample code from ConsoleReferenceClient : /// /// Handles a keep alive event from a session and triggers a reconnect if necessary. /// private void Session_KeepAlive(ISession session, KeepAliveEventArgs e) { try { // check for events from discarded sessions. if (m_session == null || !m_session.Equals(session)) { return; } } |
Replies: 1 comment
|
Answers for 1.5.376 (
For new code on 2.0, consider Closing as answered. |
Answers for 1.5.376 (
SessionReconnectHandlerworks the same way in 2.0):Reconnect). If the server no longer knows the session, for example after a server restart or a session timeout, it recreates it: it opens a new session and restores the client-side subscriptions and monitored items. WithTransferSubscriptionsOnReconnect = true, it first triesTransferSubscriptionsto move the existing server subscriptions to the new session. If that fails (for example because the server restarted and they no longer exist), it creates them again from the client's state. So yes, a…