Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

roUrlEvent returns "??" as body with 200 status code

I'm trying to fetch some JSON data from my server but about 60% of the time the roURLEvent returns "??" as the body of the request. The other 40% of the times it works as expected (the content response hasn't changed).

The code for the request is the following


function request()
    baseurl =
    token =
    url = baseurl + "/some_endpoint"
    ? "Task URL: ";url
    ? "Token: "; token
    http = createObject("roUrlTransfer")
    port = createObject("roMessagePort")
    http.addHeader("token", token)
    if http.AsyncGetToString() Then
      msg = wait(100000, port)
      if (type(msg) = "roUrlEvent")
        if (msg.getresponsecode() > 0 and  msg.getresponsecode() < 400)
          print "Task Response "
          print msg

In the debugger I print the msg headers and everything seems to be ok

    access-control-allow-origin: "*"
    cache-control: "max-age=10"
    connection: "keep-alive"
    content-encoding: "gzip"
    content-type: "application/json; charset=utf-8"
    date: "Thu, 03 Oct 2019 01:06:28 GMT"
    etag: "W/"474-4DPxJcE1OYaf4iQIgRkIlpu9KQA""
    transfer-encoding: "chunked"
    vary: "Accept-Encoding"
    x-powered-by: "..."

But everytime I print the msg.getString(), or just msg, I get "??" on the console. Also I'm pretty positive the backend is working as expected since I have 2 mobile apps running on the same server without any issues, I also double checked the url and it's the right one (since it works 40% of the time)

I'm really lost here since I don't see what could be going on. Maybe it's has to be with the encoding? but it works 40% of time so it doesn't make sense. I'm also running 2 other queries to the same server at the same time, which work mostly without issue (one of the other queries fails with the same error but only about 10% of the time)

Any ideas?

0 Kudos
Level 11

Re: roUrlEvent returns "??" as body with 200 status code

Level 7

Re: roUrlEvent returns "??" as body with 200 status code

I haven't tried that, honestly I wasn't even aware of what gzip was. Anyway, it seems to be working for now. I'll update after a bit more testing.

Thanks a lot for the help!