Execution time out in task node

Viewed 122

I'm getting the issue(Execution TimeOut) with the Task node. I created one Timer in the Scene node for Continuous Execute Function Here I Tried With Continuous Response Update With Task node and After It used in Scene Node.

'Timer

m.Update = m.top.findNode("SampleID")
m.Update .observeField("fire", "UpdateSample")
m.global.responseurl = m.urlassign
m.Update.control = "RUN"

'My Function

function UpdateSample()
    m.Sample= CreateObject("roSGNode", "SampleTask")
        m.Sample.control = "RUN"
        ?"m.global.responsecontent : " m.global.responsecontent 
end function 

'My Task Node

sub init()
?"Start Init()"
    m.DowndloadResponse = CreateObject("roUrlTransfer")
    m.DowndloadResponse.SetUrl(m.global.responseurl)
    m.Cont= m.DowndloadResponse.GetToString()
    m.global.responsecontent = m.Cont
    ?"m.global.responsecontent : " m.global.responsecontent 
?"End Init()"
end sub

Here, Not getting every time DowndloadResponse.GetToString() "Execution TimeOut". Sometimes It Gives the Error. I tried with m.top.functionname. But It's Execution at once. I also Tried with Timer Set in Task Node. But No luck. I required It's multiple. I don't know Which one is a good way to implement this. Does Anyone any idea how do solve this problem?

1 Answers

You're using the Task node incorrectly, you have to absolutely use functionName.

I would also recommend using asyncGetToString() since it'll let you read response codes. You also have to set and initialize certificates for HTTPS requests (the Roku standard cert bundle should do).

You should have something like this inside your task thread function:

request = CreateObject("roUrlTransfer")
request.retainBodyOnError(true)
request.setUrl(url)

' Needed for HTTPS requests
request.setCertificatesFile("common:/certs/ca-bundle.crt")
request.initClientCertificates()

port = CreateObject("roMessagePort")
request.setPort(port)

timeout = 0 ' Force a timeout (0 equals "indefinite", or until Roku decides to terminate the request... ~60s)
event = wait(timeout, port)

if event <> invalid and type(event) = "roUrlEvent"
    ?"event.getString() "event.getString()
    ?"event.getResponseCode() "event.getResponseCode()
    ?"event.getFailureReason() "event.getFailureReason()
end if

' Ensure the request does not continue to run after the forced timeout is hit
' (Only necessary if you set a non-zero timeout)
request.asyncCancel()
Related