Skip to content

Commit

Permalink
Added retry to start api
Browse files Browse the repository at this point in the history
  • Loading branch information
nenad0707 committed Jun 4, 2024
1 parent 64d187a commit 67ccd31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions TaskTackler/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
</CascadingAuthenticationState>

@code {
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
var httpClient = HttpClientFactory.CreateClient("api");

await PingHelper.PingApiWithRetry(httpClient);
// Start the pinging process on a background thread
_ = Task.Run(() => PingHelper.PingApiWithRetry(httpClient));
}
}
4 changes: 2 additions & 2 deletions TaskTackler/Helpers/PingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static async Task<bool> PingApi(HttpClient httpClient)

public static async Task PingApiWithRetry(HttpClient httpClient)
{
const int maxAttempts = 5;
const int delay = 5000; // 5 seconds delay between retries
const int maxAttempts = 10; // Increase the number of attempts
const int delay = 2000; // Reduce the delay to 2 seconds between retries

for (int attempt = 0; attempt < maxAttempts; attempt++)
{
Expand Down

0 comments on commit 67ccd31

Please sign in to comment.