Page 1 of 2
readurl() fails when server is slow to respond
Posted: 22 Apr 2013 23:50
by 40k
I'm getting Download Failed errors thrown by Xyplorer when I use readurl to download data from a Twitch.tv server.
It seems this server is sometimes slow to respond but will eventually send the data. By that time the script has already failed though.
I developed a while loop that keeps track of how many times the readurl fails before it pulls data from the server. The highest I have seen is 5 attempts before it reached the break function indicating data had been received.
Is it possible that the readurl and download functions can't deal with slow byte streams?
I could reproduce this bug using my code but is nested in a bigger script so it may take some time to extract it and turn it into a working standalone sample,
Re: readurl() fails when server is slow to respond
Posted: 23 Apr 2013 10:13
by admin
You get "Download Failed" also when the downloaded bytes count is smaller than the filesize initially (before the download) determined by HttpQueryInfo API. Could that be the case? I never got this case in my tests (therefore I did not give an extra error message).
Re: readurl() fails when server is slow to respond
Posted: 23 Apr 2013 23:06
by 40k
admin wrote:You get "Download Failed" also when the downloaded bytes count is smaller than the filesize initially (before the download) determined by HttpQueryInfo API. Could that be the case? I never got this case in my tests (therefore I did not give an extra error message).
Is there any way around this? Perhaps a flag that enables less than perfect byte stream downloads?
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 07:21
by admin
40k wrote:admin wrote:You get "Download Failed" also when the downloaded bytes count is smaller than the filesize initially (before the download) determined by HttpQueryInfo API. Could that be the case? I never got this case in my tests (therefore I did not give an extra error message).
Is there any way around this? Perhaps a flag that enables less than perfect byte stream downloads?
Yes, I'll add something...
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 12:38
by Marco
Don, the new "b" option for download() has to be concatenated with other options or specified separately? I mean, the correct syntax is
or
Code: Select all
download $url, $target, "o", "b";
?
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 13:08
by admin
"ob"
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 14:49
by 40k
admin wrote:40k wrote:admin wrote:You get "Download Failed" also when the downloaded bytes count is smaller than the filesize initially (before the download) determined by HttpQueryInfo API. Could that be the case? I never got this case in my tests (therefore I did not give an extra error message).
Is there any way around this? Perhaps a flag that enables less than perfect byte stream downloads?
Yes, I'll add something...
Perhaps one of the nicest things about Xyplorer is that it pretty much comes with its' own "on-call" developer

Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 14:51
by admin
So it worked?
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 14:59
by 40k
admin wrote:So it worked?
It seems you enabled it for Download() only? All my scripts are based on ReadUrl() so I'll have to set up a test script.
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:04
by admin
Yes, only Download().

Argh... tomorrow...
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:05
by admin
I'm surprised that you use ReadUrl() because it is limited to 100 MB whereas download() is not.
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:09
by Marco
admin wrote:So it worked?
I never encountered the OP's problem but so far the switch seems working. Already implemented

Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:13
by 40k
admin wrote:I'm surprised that you use ReadUrl() because it is limited to 100 MB whereas download() is not.
I'm using ReadUrl() in my Twitch script because it only needs to get about 100KB worth of information from the Twitch API at any time. Coincidentally ReadUrl() only fails in a reproducible manner when downloading from Twitch.
I'm waiting for you to release the next stable version before I'm switching my YouTube script over to Download().
I've set up the following experiment:
Code: Select all
download ("http://usher.twitch.tv/find/reckful.xml?type=any", file, o);
text readfile (file);
Using manual testing I run into "Download Failed" about once every 5 to 10 attempts if I explicitly demand the byte check.
When I leave out the byte check I have not yet encountered a "Download Failed" even after 30 attempts. This leads me to believe there may be an issue with the Twitch server response to Xyplorer HTTPquery call.
Conclusion: This "seems" to be fixed by leaving out the byte check.
Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:14
by admin
Marco wrote:admin wrote:So it worked?
I never encountered the OP's problem but so far the switch seems working. Already implemented

Well, the OP's problem WAS the bytecheck which now is OFF by default. So when you "implement" (the "b" flag) it you are back exactly where you were before the change. Sure it works!

Re: readurl() fails when server is slow to respond
Posted: 24 Apr 2013 15:19
by admin
40k wrote:Conclusion: This "seems" to be fixed by leaving out the byte check.
Ok, that's good.
Now, that little byte check was implemented years ago on a whim -- actually I never thought it would ever catch a failed byte count. Now I see that the failure may as well be caused by a wrong file size retrieval or maybe even other causes. So, what the heck, I just removed the byte check by default from ReadURL() as well. Pass "4" with the 4th parameter if you still want to have it.
Coming with next version...