Repository navigation
Description
Type of issue
- Bug
- Enhancement
- Compliance
- Question
- Help wanted
Current Behavior
Hello, I have several questions about reconnection mecanism :
Doc about TransferSubscription :
"Transfer after session reconnect: The client SessionReconnectHandler can not reconnect to the existing session, it creates a new session and tries to transfer a subscription before recreating the full subscriptions."
-
Does it mean that BeginReconnect will handle the creation of the subscription and monitored Item (not only the session) ? Even after a restart of the server (server is empty, subscriptions and monitored items are not persisted afer the restart) ?
-
Is it possible to reconnect (subscription and monitored working) using BeginReconnect method when the session is closed on the server (du to timeout for example) ?
If so, should the server implement DurableSubscription and TransferSubscription ?
In the sample, they use :
// support transfer
m_session.DeleteSubscriptionsOnClose = false;
m_session.TransferSubscriptionsOnReconnect = true;
I know sometimes the SDK send a new session with a different id from the previous one.
And in that case, my mind tell me that the sdk will transfer the subscriptions.
- When I call BeginReconnect, should I disable Keep Alive (e.CancelKeepAlive = True) even if the state is not ReconnectState.Triggered ?
That the case in the sample, but it means that BeginReconnect will moves to that state on her own ?
If so, then the client can not really log when the reconnect is starting (not completed) if i'm correct.
-
When I set e.CancelKeepAlive at True, my method Session_KeepAlive continues to be trigger. I confirm that with logs. Do I missunderstand something in the use case ?
-
Does ReconnectPeriod means that BeginReconnect will try to reconnect each ReconnectPeriod ?
Expected Behavior
No response
Steps To Reproduce
No 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;
}
// start reconnect sequence on communication error.
if (ServiceResult.IsBad(e.Status))
{
if (ReconnectPeriod <= 0)
{
Utils.LogWarning("KeepAlive status {0}, but reconnect is disabled.", e.Status);
return;
}
var state = m_reconnectHandler.BeginReconnect(m_session, m_reverseConnectManager, ReconnectPeriod, Client_ReconnectComplete);
if (state == SessionReconnectHandler.ReconnectState.Triggered)
{
Utils.LogInfo("KeepAlive status {0}, reconnect status {1}, reconnect period {2}ms.", e.Status, state, ReconnectPeriod);
}
else
{
Utils.LogInfo("KeepAlive status {0}, reconnect status {1}.", e.Status, state);
}
// cancel sending a new keep alive request, because reconnect is triggered.
e.CancelKeepAlive = true;
return;
}
}
catch (Exception exception)
{
Utils.LogError(exception, "Error in OnKeepAlive.");
}
}
Activity