ooples / OoplesFinance.YahooFinanceAPI

A .NET API wrapper for Yahoo Finance that allows users to get top trending stocks, historical stock data, stock splits, dividends, capital gains, and much much more!
Apache License 2.0
47 stars 10 forks source link

Avoid to dispose HttpClient and reset HttpClientHandler to default value #59

Closed oscar811 closed 6 months ago

oscar811 commented 6 months ago

Fix issues/56

ooples commented 6 months ago

@oscar811 I have been looking into these changes and I don't think the issue is the HttpClient getting disposed since it is the handler that needs to be kept alive. Running one unit test at a time seems to pass each time but running all of the tests at once results in around half of the tests failing due to InvalidOperationException: Handler didn't receive a response or the response header is empty and so no crumb can be found. I have a feeling that this is due to throttling on Yahoo's end but haven't confirmed this. Either way, I need to ask you to run Test Explorer in Visual Studio on your end to run all tests at the same time and you should be able to see the same errors on your end. I'm open to suggestions of course but I believe more work will need to be done to get them all to pass at once.