Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

roUrlEvent headers but no response body

I am trying to http long poll a connection using a roUrlTransfer object, however it won't return a response body either synchronously or asynchronously.

I am calling AsyncGetString() then I can see from the header in the roUrlEvent that there is a response content-length: 24 so the response should be there.

<Component: roAssociativeArray> =
{
    access-control-allow-origin: "*"
    connection: "keep-alive"
    content-length: "24"
    content-type: "application/octet-stream"
    date: "Thu, 15 Dec 2016 08:50:01 GMT"
    set-cookie: "io=CFic4Wcp-sZN-o-JAAAQ; Path=/; HttpOnly"
}

(the response should be ÿ42["message","ok then"])

any ideas why it doesn't get filled? .GetString() on the roUrlEvent returns blank

Cheers
0 Kudos
5 REPLIES 5
EnTerr
Roku Guru

Re: roUrlEvent headers but no response body

"shibuyashadows" wrote:
(the response should be ÿ42["message","ok then"])

What is this "ÿ" character you are using? Is it the two octets \xC3 \xBF (proper UTF8)?
len('42["message","ok then"]') = 23, so it seems that there is only 1 octet...

I am particularly suspicious of it because the symbol i see in my browser (y umlaut) has a code point U+00FF and if you transmitted that as a single byte \0xFF, nothing good will come out of it. 
0 Kudos

Re: roUrlEvent headers but no response body

Thanks for the reply!

The request itself is to a node.js socket.io socket, on which i call:

socket.emit('message', 'ok then');


the message is transmitted as ) (copied from running the same request in chrome and looking at the response body)

i wonder if i should be using an roStreamSocket for this?
0 Kudos
EnTerr
Roku Guru

Re: roUrlEvent headers but no response body

"shibuyashadows" wrote:
The request itself is to a node.js socket.io socket, on which i call:

umm, i don't know what the wire protocol of socket.io is... doesn't it use websockets? Roku doesn't do websockets.

the message is transmitted as ) (copied from running the same request in chrome and looking at the response body)

copy&paste from console can be misleading, can you get a hex dump of this - maybe WireShark/sniff the packet?

i wonder if i should be using an roStreamSocket for this?

nah. if worse comes to worst, you may have to use AsyncGetToFile() and then read that into roByteArray. <cringe>
0 Kudos

Re: roUrlEvent headers but no response body

socket.io will use websockets if available, if not it will use polling.

In any case I was overthinking this, I abandoned trying to use socket.io and moved to traditional long polling with a message queue at the back-end and AsyncGetString calls in a message loop on the Roku side. Works a treat.

Cheers
0 Kudos
EnTerr
Roku Guru

Re: roUrlEvent headers but no response body

Ah, bummer - so we may never know the mystery of "ÿ"  :mrgreen:

Make sure to use UTF8 encoding and no \0 (NUL) bytes and you are golden
0 Kudos