Question re download timeout setting
marksmithhfx at gmail.com
Mon Jul 24 10:03:25 EDT 2023
This is a long shot, but in case it inspires a solution, I do something like the following to upload and download files to dropbox (which I think is similar to what Matthias is suggesting as well).
put "/todoitems.sqlite" into pPath -- the path to the file on server, in this case dropbox (equivalent to your put “https…”?)
tsNetSetTimeouts 20,0,20000,60000,20,1000 -- establish a 20 second timeout (and also a slow response timeout)
dropBoxDownload pAccessToken, pPath — if successful, the file is copied into the "it” variable (equiv to your put URL theURL into tOutput?) except output goes to “it” instead of tOutput
put the result into tResult — if unsuccessful, tResult holds the error code from tsNet (I think this is dropBoxDownloads doing, but maybe something equiv is possible?) see below...
if tResult is not empty then
-- the dload did not work, do whatever you need to respond to a connection failure
put it into URL ("binfile:"&tTargetFile) -- write the data to disk
*Important: If writing to a url container fails, an error is returned in the result. For example:
put the result into tResult
> On 22 Jul 2023, at 3:55 pm, William Prothero via use-livecode <use-livecode at lists.runrev.com> wrote:
> I'll try it.
> Thanks so much for your help.
> William A. Prothero, PhD
> Prof Emeritus, Dept of Earth Science
> University of California, Santa Barbara
>> On Jul 22, 2023, at 4:32 AM, matthias rebbe via use-livecode <use-livecode at lists.runrev.com> wrote:
>> Hello Bill,
>> since V8 or so tsNET external is included in any commercial/business license.
>> Even put URL "ftp: or http: will be executed with tsNET by liburl.
>> So in case you did not manually disabletsNET for your app, you could use tsNetSetTimeouts to set timeout values.
>> By default tsNET does not limit the time a request could take and that might be the reason why the put URL takes forever.
>> The Syntax looks like this
>> tsNetSetTimeouts pDnsCacheTimeout, pRequestTimeoutMS, pConnectTimeoutMS, pAcceptTimeoutMS, pLowSpeedTime, pLowSpeedLimit
>> The second parameter is responsible for the request timeout and has to be set in milliseconds.
>> So for example
>> tsNetSetTimeouts 30, 33000, 300000, 60000, 30, 1000
>> would set the request timeout to 33 seconds. The other values in my example are the default values.
>> After the timeout the script continues and you could check if the put command returned the expected value.
>>> Am 22.07.2023 um 02:02 schrieb prothero--- via use-livecode <use-livecode at lists.runrev.com>:
>>> Sorry for the trivial question, but..
>>> I have an app on my iphone that I am updating from a several years old app the previously worked on an older version of livecode. It needs to access a mysql database on the internet. It works fine when there is internet service.
>>> I test access by downloading a file with a simple text code. If there code is returned in the message, I continue accessing the database. However, when there is no internet, the "put URL” command seems to hang forever. I’ve looked for a way to set the timeout for an internet command, but…. can’t,.
>>> Could you direct me to a simple explanation about how to set a reasonable internet not connected message?
>>> put "https://"&theURL&"/test.html" into theURL
>>> put URL theURL into tOutput —if the request times out, the output is not received.
>>> if tOutput contains "AB7699HEYIMHERE” then —code received, internet access is successful
>>> return true
>>> return false
>>> end if
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode