chaklasiyanikun
Roku Guru

Inside a Task node, When API call's Roku Device Restart's Automatically.

I tried to API call using below logic inside a Task node.

I test using the Postman tool My File Response takes around 800ms. I applied different below logic and the Results inside a Task node For fetch response from API.

'First Logic

url = "http://MyAPIHost:port/API.json"
rxfer.SetUrl(url)
m.raw = rxfer.GetToString()
json = ParseJSON(m.raw)

'When I performed the First logic. Results are below : 

When the Application launch :

  1. First Time Device Restarted
  2. Second Time It's Give Execution Timeout error
  3. Third Time It's working

'Second Logic

url = "http://MyAPIHost:port/API.json"
rxfer.SetUrl(url)
m.port = CreateObject("roMessagePort")
rxfer.SetPort(m.port)
rxfer.AsyncGetToString()
m.msg = wait(3000,m.port)
if m.msg = invalid then 
   rxfer.AsyncCancel()
else
   m.raw = m.msg.GetString()
   ?"m.raw : "m.raw
end if 
json = ParseJSON(m.raw)

'When I performed the Second logic. Results are below : 

When the Application launch :

  1. First Time Device Restarted
  2. Second Time Device Restarted
  3. Third Time It's Give Execution Timeout error
  4. Fourth Time It's Give Execution Timeout error
  5. Fifth Time It's working

Third Logic(Using Internal File):

m.raw = ReadASCIIFile("pkg:/api/API.json")
json = ParseJSON(m.raw)

'When I performed the Third logic. Results are below : 

When the Application launch :

  1. First Time It's Working

I don't understand one thing. It's giving a Execution timeout error. It's ok but why Roku Device restart's the Automatic. Does any one knows about this issue?

Tags (1)
0 Kudos
2 REPLIES 2
norcaljohnny
Roku Guru

Re: Inside a Task node, When API call's Roku Device Restart's Automatically.

You are not creating a roUrlTransfer object.

url = "http://MyAPIHostSort/API.json"
rxfer = CreateObject("roUrlTransfer")
rxfer.SetUrl(url)
m.raw = rxfer.GetToString()
json = ParseJSON(m.raw)
print json

 

0 Kudos
chaklasiyanikun
Roku Guru

Re: Inside a Task node, When API call's Roku Device Restart's Automatically.

I have already created the roUrlTransfer object. I wrote code in short for better visibility.

0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!