Failing with Status code 502 since Dec 4?
emoreau99 opened this issue · comments
Hi
Anybody else experiencing a "Flurl.Http.FlurlHttpException : Call failed with status code 502 (Connection timed out): GET https://fc.yahoo.com" error since Dec. 4?
Anyone found a workaround?
me too, since since Dec. 4 too
I am hitting the same too.
found a workaround that seems to work.
In the InitAsync method of the "internal static class YahooSession" class:
-on the line : var response = await "https://login.yahoo.com"
-replace login with fc
-replace the line "_cookie = response.Cookies[0];"
-with : _cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
Those changes did not work. The response here still throws 502. May be you have some other changes on machine that helped along with these 2 changes ?
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("404")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
The workaround from @emoreau99 worked well for me, with the following clarification:
-replace login with fc
For me, I did the opposite. I had "fc.yahoo.com" on that line, and I replaced it with "login.yahoo.com". Everything worked then. The implication being that "fc.yahoo.com" is no longer responding.
hmm I tried both and none of them worked.
@kamoco My code now looks like this:
public static async Task InitAsync(CancellationToken token = default)
{
if (_crumb != null)
{
return;
}
await _semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
const string userAgentKey = "User-Agent";
const string userAgentValue = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = await "https://login.yahoo.com"
.AllowHttpStatus("404")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (response.Cookies.Count == 0)
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
This worked for me:
change login to fc
Allow 502
replace the _cookie line - _cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("502")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (response.Cookies.Count == 0)
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
//_cookie = response.Cookies[0];
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
For me the request to "https://fc.yahoo.com" runs into a timeout and if I try "https://login.yahoo.com" I only get a cookie with name "AS". With this cookie the next request (_crumb = await "https://query1.finance.yahoo.com/v1/test/getcrumb") throws an error.
Same as above. Location in Germany, just in case this matters.
Note I used _cookie = response.Cookies[0] as the above suggested FirstOrDefault fails.
The fetched _cookie has Name is "AS" and Value a very long string.
The exception message is:
"Call failed with status code 500 (Internal Server Error): GET https://query1.finance.yahoo.com/v1/test/getcrumb"
I missed the part with "Allow 502". With this change it works again. Thank you @kamoco !
This is how my method looks now:
public static async Task InitAsync(CancellationToken token = default)
{
if (_crumb != null)
{
return;
}
await _semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
const string userAgentKey = "User-Agent";
const string userAgentValue = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = await "https://fc.yahoo.com/"
.AllowHttpStatus("502")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (!response.Cookies.Any(c => c.Name == "A3"))
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
_crumb = await "https://query1.finance.yahoo.com/v1/test/getcrumb"
.WithCookie(_cookie.Name, _cookie.Value)
.WithHeader(userAgentKey, userAgentValue)
.GetAsync(token)
.ReceiveString();
if (string.IsNullOrEmpty(_crumb))
{
throw new Exception("Failed to retrieve Yahoo crumb.");
}
}
}
finally
{
_semaphore.Release();
}
}
Thanks mate! Changing to 502 worked for me too!
I noticed though that the invocation of the following takes long time to complete. About 30 secs. Any idea why this is happening?
I guess is some timeout setting. At least, it is invoked only once and afterwards the feeds are fetched without delay by using the discovered cookie.
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("502")//works after 5.12.23
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
Thank all, I had same problem and its now working again.