FlareSolverrSharp
FlareSolverrSharp copied to clipboard
Help needed: Correct way to use FlareSolverrSharp with .net 6/7 dependency injection
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?
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 });