Skip to content

Commit 773af55

Browse files
marcschierCopilot
andauthored
Fix session reconnect handler (OPCFoundation#3471)
* Fix session reconnect handler * Update Libraries/Opc.Ua.Client/Session/SessionReconnectHandler.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 288f02f commit 773af55

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Libraries/Opc.Ua.Client/Session/SessionReconnectHandler.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,22 @@ or StatusCodes.BadNoCommunication
512512
try
513513
{
514514
ISession session;
515-
if (transportChannel == null)
516-
{
517-
throw ServiceResultException.Unexpected(
518-
"Transport channel is null for reverse connect session recreation.");
519-
}
520515
if (m_reverseConnectManager != null)
521516
{
522517
ITransportWaitingConnection? connection;
523518
do
524519
{
525-
EndpointDescription endpointDescription =
526-
current.Endpoint ?? transportChannel.EndpointDescription;
527-
520+
EndpointDescription? endpointDescription =
521+
current.Endpoint ?? transportChannel?.EndpointDescription;
522+
if (endpointDescription == null)
523+
{
524+
throw ServiceResultException.Unexpected(
525+
"EndpointDescription is null for reverse connect session recreation.");
526+
}
528527
connection = await m_reverseConnectManager
529528
.WaitForConnectionAsync(
530529
new Uri(endpointDescription.EndpointUrl),
531-
endpointDescription.Server.ApplicationUri)
530+
endpointDescription.Server?.ApplicationUri)
532531
.ConfigureAwait(false);
533532

534533
if (m_updateFromServer)
@@ -564,10 +563,13 @@ await endpoint
564563
.ConfigureAwait(false);
565564
m_updateFromServer = false;
566565
}
567-
568-
session = await current
569-
.SessionFactory.RecreateAsync(current, transportChannel)
570-
.ConfigureAwait(false);
566+
session = transportChannel == null
567+
? await current
568+
.SessionFactory.RecreateAsync(current)
569+
.ConfigureAwait(false)
570+
: await current
571+
.SessionFactory.RecreateAsync(current, transportChannel)
572+
.ConfigureAwait(false);
571573
}
572574
// note: the template session is not connected at this point
573575
// and must be disposed by the owner

0 commit comments

Comments
 (0)