feat: WIP on retry logic
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
using Activity = StevesBot.Worker.Discord.Gateway.Events.Data.Activity;
|
using Activity = StevesBot.Worker.Discord.Gateway.Events.Data.Activity;
|
||||||
|
|
||||||
namespace StevesBot.Worker.Discord.Gateway;
|
namespace StevesBot.Worker.Discord.Gateway;
|
||||||
@@ -674,7 +675,23 @@ internal sealed class DiscordGatewayClient : IDiscordGatewayClient
|
|||||||
throw new DiscordGatewayClientException("WebSocket is already open. Cannot connect.");
|
throw new DiscordGatewayClientException("WebSocket is already open. Cannot connect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
await _webSocket.ConnectAsync(uri, cancellationToken);
|
var connected = false;
|
||||||
|
var attempts = 0;
|
||||||
|
var delay = TimeSpan.FromSeconds(0);
|
||||||
|
|
||||||
|
while (connected is false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Task.Delay(delay, cancellationToken);
|
||||||
|
await _webSocket.ConnectAsync(uri, cancellationToken);
|
||||||
|
connected = true;
|
||||||
|
}
|
||||||
|
catch (Exception e) when (e is WebSocketException)
|
||||||
|
{
|
||||||
|
// TODO: Implement exponential backoff retry strategy
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Uri BuildUri(string url)
|
private static Uri BuildUri(string url)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
global using System.Net;
|
||||||
global using System.Net.WebSockets;
|
global using System.Net.WebSockets;
|
||||||
global using System.Reflection;
|
global using System.Reflection;
|
||||||
global using System.Text;
|
global using System.Text;
|
||||||
@@ -19,4 +20,4 @@ global using StevesBot.Worker.Discord.Gateway.Events.Data;
|
|||||||
global using StevesBot.Worker.Handlers;
|
global using StevesBot.Worker.Handlers;
|
||||||
global using StevesBot.Worker.Telemetry;
|
global using StevesBot.Worker.Telemetry;
|
||||||
global using StevesBot.Worker.Threading;
|
global using StevesBot.Worker.Threading;
|
||||||
global using StevesBot.Worker.WebSockets;
|
global using StevesBot.Worker.WebSockets;
|
||||||
|
|||||||
Reference in New Issue
Block a user