Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: Failure to create client #52

Closed
stagnoman opened this issue Apr 28, 2022 · 27 comments
Closed

Exception: Failure to create client #52

stagnoman opened this issue Apr 28, 2022 · 27 comments

Comments

@stagnoman
Copy link

Hi there,

I have always successfully used YahooFinanceApi. Today I am getting the following exception using "GetHistoricalAsync": Exception: Failure to create client. Could you kindly tell me what I can do to resolve the exception?

Many Thks for your help
Regards
error

LUCA

@dshe
Copy link
Collaborator

dshe commented Apr 29, 2022

I suggest you try: https://github.com/dshe/YahooQuotesApi

@sebduu
Copy link

sebduu commented Apr 29, 2022

Same problem for me....

@sebduu
Copy link

sebduu commented Apr 29, 2022

I suggest you try: https://github.com/dshe/YahooQuotesApi

My program is in VB.net, can I use a C# Api with?

@giorgiovaccarino
Copy link

"I suggest you try: https://github.com/dshe/YahooQuotesApi"

give me this problem:

YahooHistory: failure to reset HttpClient.
in YahooQuotesApi.YahooHistoryRequester.d__9.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistoryRequester.cs: riga 98
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() in YahooQuotesApi.YahooHistoryRequester.<Reset>d__8.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistoryRequester.cs: riga 67 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in YahooQuotesApi.YahooHistoryRequester.<Request>d__7.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistoryRequester.cs: riga 35 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.YahooHistory.d__71.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistory.cs: riga 65 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.ParallelProducerCache2.<Get>d__4.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\Utilities\ParallelProducerCache.cs: riga 34 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.YahooHistory.d__61.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistory.cs: riga 36 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.YahooQuotes.<b__12_0>d.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 142
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult()
in System.Threading.Tasks.Parallel.<>c__501.<<ForEachAsync>b__50_0>d.MoveNext() in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in YahooQuotesApi.YahooQuotes.<AddHistoryToSecurities>d__12.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 157 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in YahooQuotesApi.YahooQuotes.<GetSecuritiesAsync>d__10.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 93 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.YahooQuotes.d__9.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 68
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() in YahooQuotesApi.YahooQuotes.<GetAsync>d__7.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 45 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
in YahooQuotesApi.YahooQuotes.d__6.MoveNext() in C:\projects\yahooquotesapi\YahooQuotesApi\YahooQuotes.cs: riga 29
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
in Ts.Core.MarketData.YahooConnector2.<>c__DisplayClass6_0.<b__0>d.MoveNext() in C:\Users\giorg\source\repos\TS\Ts.Core\MarketData\YahooConnector2.cs: riga 34

@stagnoman
Copy link
Author

Hi all,
thks a lot
in case YahooFinanceApi doesn't work anymore, I will switch to yfinance

@DonWM
Copy link

DonWM commented Apr 30, 2022

I had same problem getting history data from Yahoo on both YahooFinanceAPI and YahooQuotesAPI. Did yahoo change something to break the code? Did windows have an update that broke the code?

Both work to get current quotes - just not the history.

I can get yahoo history data using python's pandas_datareader without a problem but I need it from C#,

@stagnoman
Copy link
Author

honestly speaking, I had no time to deeply investigate the problem yet. I believe it is protocol http client request vs yahoo server but I am not sure. (maybe ... HTTP2 vs HTTP1)
For the time being, I solved the problem using yfinance that is widely supported and used in the community. It is easy to wrap into a C# project without any performance loss.

@DonWM
Copy link

DonWM commented May 1, 2022 via email

@fancyplot
Copy link

Hi, I looked into the code. The problem is that now cookies are empty in response from yahoo finance and that's why it doesn't pass the check that cookies shouldn't be empty. This is the code where it fails https://github.com/karlwancl/YahooFinanceApi/blob/master/YahooFinanceApi/YahooClientFactory.cs. I removed that check and also modified the code for retrieving a crumb. For me now it works fine. I'd push the branch but seems I don't have access rights on doing this.

@stagnoman
Copy link
Author

Great thks! I modified the dll removing check too, It works perfectly!

@stagnoman stagnoman reopened this May 3, 2022
@sebduu
Copy link

sebduu commented May 3, 2022

good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation.

@stagnoman
Copy link
Author

stagnoman commented May 3, 2022

good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation.

hi,
1\ open your program in visual studio
2\ go in references, remove existing YahooFinanceApi.dll,
2\ unzip attached dll. Then in references: right mouse button, add reference and use YahooFinanceApi.dll unzipped
3\ rebuild solution

@stagnoman
Copy link
Author

good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation.

Hi pls disregard the previous dll attached. It doesn't work.
I am working on it.
I will send you late afternoon
Ciao

@stagnoman
Copy link
Author

good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation.

Pls replace your old YahooFinanceApi.dll with this attached below.
YahooFinanceApi.zip

Ciaoooo

@DonWM
Copy link

DonWM commented May 4, 2022 via email

@sebduu
Copy link

sebduu commented May 4, 2022

good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation.

Pls replace your old YahooFinanceApi.dll with this attached below. YahooFinanceApi.zip

Ciaoooo

Yes it works again, thank you !!

@stagnoman
Copy link
Author

stagnoman commented May 4, 2022

Is this YahooFinanceApi.dll now ok? Will there be a normal upgrade through NuGet for this - a new version 2.1.3? There is also an a 3.0.0-beta3 but is has lots of changes and isn’t very compatible with 2.1.2. I’ve avoided using this so far since it is so different. Thanks, Don From: stagnoman @.> Sent: Wednesday, May 4, 2022 5:53 AM To: karlwancl/YahooFinanceApi @.> Cc: DonWM @.>; Comment @.> Subject: Re: [karlwancl/YahooFinanceApi] Exception: Failure to create client (Issue #52) good news ! Can someone explain how to remove the check? I'm not familiar with this kind of programation. Pls replace your old YahooFinanceApi.dll with this attached below. YahooFinanceApi.zip https://github.com/karlwancl/YahooFinanceApi/files/8620456/YahooFinanceApi.zip Ciaoooo — Reply to this email directly, view it on GitHub <#52 (comment)> , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQQC4L2CZPWVLFLPXIM54LVIJXLHANCNFSM5UT2IF3A . You are receiving this because you commented. https://github.com/notifications/beacon/AHQQC4JDI2ERAV42MDS7KBDVIJXLHA5CNFSM5UT2IF3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIKME4DQ.gif Message ID: @.*** @.***> >

Is this YahooFinanceApi.dll now ok? Yes, it works.
Will there be a normal upgrade through NuGet for this - a new version 2.1.3? No, in Nuget there is the old one. You have to replace the old dll with mine attached above manually in VS, build the program then.

There is also an a 3.0.0-beta3 but is has lots of changes and isn’t very compatible with 2.1.2. I’ve avoided using this so far since it is so different. Dll above is still net 2.0

@Callightman
Copy link

For me it does'nt work after 5-6 querry it responds with 401 error

@stagnoman
Copy link
Author

The 401 error was also happening with old dll. Yahoo has implemented some kind of time out defense against sever overloading and potential ddos attacks by tracking the number / frequency of requests from a specific ip address.
A 401 error code means the user is unauthorised.

To avoid the error, the method must be synchronous. I use a Thread.Sleep pause of 500 ms,/1s between requests.
Avoid any parallelism.

@Callightman
Copy link

Using synchronous calls and 1 second delay has solved the problem.

@brutm
Copy link

brutm commented May 13, 2022

@lucastagnitta thanks for your dll but i have a problem. Assembly errors with Flurl

@stagnoman
Copy link
Author

@lucastagnitta thanks for your dll but i have a problem. Assembly errors with Flurl

In the past, I got some troubles as well, I am using the following version, installed manually
Flurl 2.5.2
Flurl.Http 2.1.0

@dshe
Copy link
Collaborator

dshe commented May 15, 2022

I suggest you try the new version (5.1): https://github.com/dshe/YahooQuotesApi

@kyi87
Copy link

kyi87 commented May 16, 2022

Hi, I looked into the code. The problem is that now cookies are empty in response from yahoo finance and that's why it doesn't pass the check that cookies shouldn't be empty. This is the code where it fails https://github.com/karlwancl/YahooFinanceApi/blob/master/YahooFinanceApi/YahooClientFactory.cs. I removed that check and also modified the code for retrieving a crumb. For me now it works fine. I'd push the branch but seems I don't have access rights on doing this.

Could you please show your exact changes in "YahooClientFactory.cs"? Would be very helpful. Thank you!

@fancyplot
Copy link

YahooFinanceApi.zip
This are my changes that I made to the code in master branch. Just replace files in original solution with files from archive and than rebuild.

@kyi87
Copy link

kyi87 commented May 24, 2022

YahooFinanceApi.zip This are my changes that I made to the code in master branch. Just replace files in original solution with files from archive and than rebuild.

Thanks for the Code. Now i experience errors after the change and after several requests:

"Call failed with status code 401 (Unauthorized)"

Do you experienced the same problem?

@stagnoman
Copy link
Author

YahooFinanceApi.zip This are my changes that I made to the code in master branch. Just replace files in original solution with files from archive and than rebuild.

Thanks for the Code. Now i experience errors after the change and after several requests:

"Call failed with status code 401 (Unauthorized)"

Do you experienced the same problem?

yes, the 401 error was also happening with old dll. Yahoo has implemented some kind of time out defense against sever overloading and potential ddos attacks by tracking the number / frequency of requests from a specific ip address.
A 401 error code means the user is unauthorised.

To avoid the error, the method must be synchronous. I use a Thread.Sleep pause of 500 ms,/1s between requests.
Avoid any parallelism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants