3

The AsyncPostFromString method from roUrlTransfer object generates a CURL request with a timeout of 30secs.

i.e

port = CreateObject ("roMessagePort")
ut = CreateObject ("roUrlTransfer")
ut.setMessagePort(port)
ut.AsyncPostFromString(data)

Does anyone know if there's any way to change the default value for CURL timeout using Roku SDK?

André Leal
  • 186
  • 1
  • 8

2 Answers2

0

I don't think so - or such option would be mentioned somewhere in https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer - just like there is a call to set minimum transfer rate.

But try asking the question in Roku's dev.forum http://forums.roku.com/viewforum.php?f=34 - potentially they may add the feature.

Nas Banov
  • 28,347
  • 6
  • 48
  • 67
  • I have found some problem with Roku. You found Is there any solution. In Postmantool my response time is 1 min, But I set 0 by default. and apply also roTimeSpan to set millisecond or second But Its give an error (execution timeout (runtime error &h23)). Is their available any solution in Roku? – Nikunj Chaklasiya Sep 20 '19 at 06:40
0

There is no way to change the default timeout of a request. But you can do this manually when managing the timeout in your async request handler. Most applications should be using async requests, so you'll be doing similar checks anyway. Also be sure to call asyncCancel() on the roUrlTransfer to clean up the request.

' given a url that will timeout
url = "http://www.mocky.io/v2/5a75d6902e000068006ab21a?mocky-delay=1000ms"

' and a timeout in ms
timeout = 100

' create a roUrlTransfer for the request
urlTransfer = CreateObject("roUrlTransfer")
urlTransfer.setUrl(url)
port = CreateObject("roMessagePort")
urlTransfer.setMessagePort(port)

' request the URL
if urlTransfer.asyncGetToString()
    event = wait(timeout, port)
    if type(event) = "roUrlEvent"
        print "urlTransfer success"

    else if event <> invalid
        print "event emitted: " + type(event)

    else
        print "urlTransfer timed out"
        urlTransfer.asyncCancel()

        ' alternatively: measure the request time against timeout using roTimeSpan
    end if
end if

As noted in the code, you will want to measure the timeout using an roTimeSpan if you are handling other requests in your wait loop (in cases where the wait timeout is not the same as the request timeout).

Jess Bowers
  • 2,846
  • 1
  • 22
  • 42
  • Hello @Jess Bowers, I required to display a dialog in `urlTransfer.asynccancel()` Block. But Task node doesn't Support Dialog. Is there any way to display for dialog. I tried so much way using getparent() But not displaying yet. – Nikunj Chaklasiya Mar 12 '20 at 05:44