readurl() fails when server is slow to respond

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
40k
Posts: 234
Joined: 09 Dec 2011 21:25

readurl() fails when server is slow to respond

Post 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,
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post 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).

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: readurl() fails when server is slow to respond

Post 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?
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post 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...

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: readurl() fails when server is slow to respond

Post 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

Code: Select all

 download $url, $target, "ob";
or

Code: Select all

 download $url, $target, "o", "b";
?
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post by admin »

"ob"

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: readurl() fails when server is slow to respond

Post 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 :)
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post by admin »

So it worked?

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: readurl() fails when server is slow to respond

Post 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.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post by admin »

Yes, only Download(). :| Argh... tomorrow...

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post by admin »

I'm surprised that you use ReadUrl() because it is limited to 100 MB whereas download() is not.

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: readurl() fails when server is slow to respond

Post by Marco »

admin wrote:So it worked?
I never encountered the OP's problem but so far the switch seems working. Already implemented 8)
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: readurl() fails when server is slow to respond

Post 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.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post 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 8)
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! :P

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: readurl() fails when server is slow to respond

Post 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...

Post Reply