chaklasiyanikun
5 years agoRoku Guru
How To Manage Response From Task Node With Slow Internet?
I access My Task node in Main Scene Like below.
sub init()
m.Response = CreateObject("roSGNode", "TaskNodeFile") m.Response.control = "RUN"
end sub
And Task node Code Like below.
sub init() ?"init() - Start" readdata = CreateObject("roUrlTransfer") data = "http://Domain:Port" readdata.setUrl(data) readdata.SetMinimumTransferRate(1, 75) ? "data is " data m.port = CreateObject("roMessagePort") readdata.setport(m.port) readdata.gettostring() readdata.SetRequest("POST") request = readdata.AsyncPostFromString(data) ?"request : " request while (true) msg = Wait(3000, m.port) 'Here It's Crashed. I also tried with the 0 MilliSecond. " It's Give a Execution Time Out statusCode = msg.GetResponseCode() if (Type(msg) = "roUrlEvent") statusCode = msg.GetResponseCode() headers = msg.GetResponseHeaders() if msg.getresponsecode() = 200 then Response = msg.getstring() headers = msg.getresponseheadersarray() ?"Response : " Response exit while else m.top.isError = "true" m.readdata.asynccancel() exit while end if
else ? "wait for data" end if end while end sub
Here the issue is: I tested this Code with 2 Roku premiere+ devices.
In 1st Device Internet Speed: 10mbps and
In 2nd Device Internet Speed: 50mbps.
I checked My API Response using the Postman tool :
With 10mbps: It takes an 1800 MilliSeconds
With 50mbps: It takes a 350 MilliSeconds
In My Case With 10 Mbps, The Application crashed with this line msg = Wait(3000, m.port). Here, I also tried with the 0 MilliSeconds. After also It's Crashed and Gives Execution Timeout. If Some Internet issues, It's no waiting. It's Directly Crashed. Does anyone Found Good solutions or How to handle this Scenario?.