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.
“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.
“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.
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.