mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-13 02:46:20 +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>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="request">The original request</param>
|
/// <param name="subscription">The subscription</param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <summary>
|
||||||
|
@ -295,6 +295,8 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
|
|
||||||
// Can't wait for this as it would cause a deadlock
|
// Can't wait for this as it would cause a deadlock
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var reconnectSuccessful = await ProcessReconnectAsync().ConfigureAwait(false);
|
var reconnectSuccessful = await ProcessReconnectAsync().ConfigureAwait(false);
|
||||||
if (!reconnectSuccessful)
|
if (!reconnectSuccessful)
|
||||||
@ -311,6 +313,12 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
DisconnectTime = null;
|
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;
|
return Task.CompletedTask;
|
||||||
@ -755,7 +763,7 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, $"[Sckt {SocketId}] failed request revitalization: " + result.Error);
|
_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