shibuyashadows
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016
12:59 AM
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
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
5 REPLIES 5
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016
03:31 AM
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.
shibuyashadows
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016
04:10 AM
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:
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?
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?
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016
04:41 AM
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>
shibuyashadows
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2016
01:10 AM
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
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
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2016
09:03 AM
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
Make sure to use UTF8 encoding and no \0 (NUL) bytes and you are golden