FlareSolverrSharp icon indicating copy to clipboard operation
FlareSolverrSharp copied to clipboard

Help needed: Correct way to use FlareSolverrSharp with .net 6/7 dependency injection

Open TheBinaryLoop opened this issue 2 years ago • 1 comments

Hi,

I'm currently trying to use FlareSolverrSharp in one of my applications. Microsoft recommends to use a IHttpClientFactory for dependency injection. This library doesn't seem compatible with that. I always get this error: System.InvalidOperationException: The 'InnerHandler' property must be null. 'DelegatingHandler' instances provided to 'HttpMessageHandlerBuilder' must not be reused or cached. Handler: 'FlareSolverrSharp.ClearanceHandler'

Is it possible to use it like I'm currently trying to do?

TheBinaryLoop avatar Sep 18 '23 17:09 TheBinaryLoop

in ConfigureServices, this is what i added

services.AddHttpClient(System.Reflection.Assembly.GetEntryAssembly().FullName, client => { client.Timeout = TimeSpan.FromSeconds(500); //500 second timeout error, occassionally occurs }).ConfigurePrimaryHttpMessageHandler(builder => new ClearanceHandler("http://localhost:8191/") { MaxTimeout = 2 * (60 * 1000) //2 minutes });

asulwer avatar May 07 '24 17:05 asulwer