Timeout Strategies for the Wait Method

The default timeout value for the Wait method is 21,805,184 milliseconds, which is approximately 6 hours. The timeout value is a SIGNED LONG data type, meaning its maximum possible value is 2,147,483,647 milliseconds, which is roughly 596.5 hours or just under 25 days.  This is probably enough time for even the slowest transfer.

The Wait method supports a "0" timeout value which means "keep waiting forever or until the transfer reaches a state of CANCELED, FINISHED, ERROR, SUSPENDED, SKIPPED, or BLOCKED."

You can also write scripts so that they check the condition of a transfer and if it is still in the "TRANSFERRING" state, to wait on it again.

Three timeout strategies for long transfer tasks

  1. Specify a large timeout value in the script call - Because the first parameter to the Wait method is a task index, this example uses a "-1" which means "current task." For this example, the timeout is set for 10 hours or, 10 * 60 * 60 * 1000 = 36000000 milliseconds.

    Example

         strResult = strataFTP.Wait( -1, 36000000 )

  2. After a Wait() function has timed out, check the STATUS of the transfer - In this scenario, use the program (or script) logic to keep trying after a Wait times out when the transfer is still in the TRANSFERRING state. In other words, your polling for the termination status has timed out, but not necessarily the transfer itself, so you keep going.
    In the following example, you wait up to 10 hours for the transfer, and if that times out, you check the status of the transfer. If it is still TRANSFERRING, you do it again (please note the last two conditional statements):

    Example

     Do

    strResult = strataFTP.Wait( -1, 36000000 )

    Loop While ( strResult <> "CANCELED") and ( strResult <> "FINISHED" ) and

    ( strResult <> "ERROR" ) and ( strResult <> "SKIPPED" ) and

    ( strResult <> "SUSPENDED" ) and ( strResult <> "BLOCKED" )

    Alternatively, you can take the more positive outlook of continuing on while the transfer task is either WORKING, CONNECTING, or TRANSFERRING:

    Example

    Do

    strResult = strataFTP.Wait( -1, 36000000 )

       Loop While ( strResult = "TRANSFERRING") or ( strResult = "WORKING" ) or

            ( strResult = "CONNECTING" )

  3. Wait forever, or until the transfer reaches some termination point.Most transfers eventually either FINISH or receive an error from the server; but there is a minor chance that the transfer in the queue is perpetually stuck in a "TRANSFERRING" state. This strategy might be considered a little riskier than the first two:

    Example

         strResult = strataFTP.Wait( -1, 0 )