private void OnHandshakeComplete(IAsyncResult result)
{
lock (DataLock)
{
try
{
if (m_handshakeOperation == null)
{
return;
}
Utils.Trace("Channel {0}: OnHandshakeComplete", ChannelId);
m_handshakeOperation.End(Int32.MaxValue);
m_handshakeOperation = null;
m_reconnecting = false;
}
catch (Exception e)
{
Utils.Trace(e, "Channel {0}: Handshake Failed {1}", ChannelId, e.Message);
m_handshakeOperation = null;
m_reconnecting = false;
ServiceResult error = ServiceResult.Create(e, StatusCodes.BadUnexpectedError, "Unexpected error reconnecting or renewing a token.");
// check for expired channel or token.
if (error.Code == StatusCodes.BadTcpSecureChannelUnknown || error.Code == StatusCodes.BadSecurityChecksFailed)
{
Utils.Trace("Channel {0}: Cannot Recover Channel", ChannelId);
Shutdown(error);
return;
}
ForceReconnect(ServiceResult.Create(e, StatusCodes.BadUnexpectedError, "Unexpected error reconnecting or renewing a token."));
}
}
}