Skip to content

Commit

Permalink
Return FlareSolverr timeout message
Browse files Browse the repository at this point in the history
  • Loading branch information
ngosang committed Jan 5, 2023
1 parent e9f81a6 commit 6e4ab75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/FlareSolverrSharp/Solvers/FlareSolverr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ await Locker.LockAsync(async () =>
try
{
_httpClient = new HttpClient();
_httpClient.Timeout = TimeSpan.FromMilliseconds(MaxTimeout);
// wait 2 more seconds to make sure we return the FlareSolverr timeout message
_httpClient.Timeout = TimeSpan.FromMilliseconds(MaxTimeout + 2000);
response = await _httpClient.PostAsync(_flareSolverrUri, flareSolverrRequest);
}
catch (HttpRequestException e)
Expand Down
4 changes: 2 additions & 2 deletions test/FlareSolverrSharp.Tests/ClearanceHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public async Task SolveErrorTimeout()
{
var handler = new ClearanceHandler(Settings.FlareSolverrApiUrl)
{
MaxTimeout = 100
MaxTimeout = 200
};

var client = new HttpClient(handler);
Expand All @@ -299,7 +299,7 @@ public async Task SolveErrorTimeout()
}
catch (HttpRequestException e)
{
Assert.IsTrue(e.Message.Contains("The request was canceled due to the configured HttpClient.Timeout of 0.1 seconds elapsing"));
Assert.IsTrue(e.Message.Contains("FlareSolverr was unable to process the request, please check FlareSolverr logs. Message: Error: Error solving the challenge. Timeout after 0.2 seconds."));
}
catch (Exception e)
{
Expand Down

0 comments on commit 6e4ab75

Please sign in to comment.