mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-12 02:16:23 +00:00
Updated revitalize request signature, added exception handler reconnect logic
This commit is contained in:
parent
68e525ab9d
commit
f917bf0e3f
@ -424,13 +424,13 @@ namespace CryptoExchange.Net
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the original request to send when the connection is restored after disconnecting. Can be used to update an authentication token for example.
|
||||
/// Update the subscription when the connection is restored after disconnecting. Can be used to update an authentication token for example.
|
||||
/// </summary>
|
||||
/// <param name="request">The original request</param>
|
||||
/// <param name="subscription">The subscription</param>
|
||||
/// <returns></returns>
|
||||
protected internal virtual Task<CallResult<object>> RevitalizeRequestAsync(object request)
|
||||
protected internal virtual Task<CallResult> RevitalizeRequestAsync(Subscription subscription)
|
||||
{
|
||||
return Task.FromResult(new CallResult<object>(request));
|
||||
return Task.FromResult(new CallResult(null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -295,6 +295,8 @@ namespace CryptoExchange.Net.Sockets
|
||||
|
||||
// Can't wait for this as it would cause a deadlock
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var reconnectSuccessful = await ProcessReconnectAsync().ConfigureAwait(false);
|
||||
if (!reconnectSuccessful)
|
||||
@ -311,6 +313,12 @@ namespace CryptoExchange.Net.Sockets
|
||||
DisconnectTime = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, ex, $"[Sckt {SocketId}] Unknown exception while processing reconnection, reconnecting again");
|
||||
_ = _socket.ReconnectAsync().ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -755,7 +763,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
if (!result)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, $"[Sckt {SocketId}] failed request revitalization: " + result.Error);
|
||||
return result.As(false);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user