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: 
EnTerr
Roku Guru

Re: External Control changes?

-v is your friend:
$ curl -v "http://192.168.1.28:8060/query/apps HTTP/1.1\r\n"
* About to connect() to 192.168.1.28 port 8060 (#0)
* Trying 192.168.1.28...
* Adding handle: conn: 0x7fbbd0804400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fbbd0804400) send_pipe: 1, recv_pipe: 0
* Connected to 192.168.1.28 (192.168.1.28) port 8060 (#0)
> GET /query/apps HTTP/1.1\r\n HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 192.168.1.28:8060
> Accept: */*
>
< HTTP/1.1 400 Bad Request
* Server Roku UPnP/1.0 MiniUPnPd/1.4 is not blacklisted
< Server: Roku UPnP/1.0 MiniUPnPd/1.4
< Content-Length: 0

See where it says "GET /query/apps HTTP/1.1\r\n HTTP/1.1"? Yes, have no business manually slapping "HTTP/...".

And btw, this doesn't even send CR+LF but the 4 characters \ r \ n. I wondered how is that done in shell and seems the right way is $'yada \r\n yada'. But regardless, it won't work even then.
0 Kudos
mjrtoo
Binge Watcher

Re: External Control changes?

So back to the first post. The same thing happens with the GET request, 400 error. This had been working for over a year, there's nothing wrong with the old code, here is a code snippet from the program, \x being the escape character for this compiler to concatenate the CR-LF-CR-LF onto the end of the statement.

tx$ = "GET /query/apps\x0D\x0A\x0D\x0A";


and

tx$ =  "curl http://192.168.1.233:8060/query/apps\x0D\x0A\x0D\x0A"


Results in the exact same 400 error, using the -v did not print out a more verbose message in my console.

(\r and \n are shortcuts in this compiler, but I've changed it to be straight up hex as above)
0 Kudos
RokuMarkn
Visitor

Re: External Control changes?

Ok, you're still confused. The curl command should be typed in a Linux shell, not sent to the unit via some programmatic networking API. The curl command doesn't need any CR-LFs at the end. The GET line needs the CR-LFs at the end. Without seeing more of your code it's hard to say what you're doing wrong, but it doesn't look like you're sending the Host header, which is also required in HTTP 1.1. Did you confirm that it works in a browser as EnTerr suggested?

--Mark
0 Kudos
mjrtoo
Binge Watcher

Re: External Control changes?

"RokuMarkn" wrote:
Ok, you're still confused. The curl command should be typed in a Linux shell, not sent to the unit via some programmatic networking API. The curl command doesn't need any CR-LFs at the end. The GET line needs the CR-LFs at the end. Without seeing more of your code it's hard to say what you're doing wrong, but it doesn't look like you're sending the Host header, which is also required in HTTP 1.1. Did you confirm that it works in a browser as EnTerr suggested?

--Mark


The only thing I'm confused about is why it stopped working with the GET after over a year of operation. Did something change in the way I need to send this data? Seriously, all I was doing previously is opening a client to 192.168.1.233:8060, and upon a connection, send "GET /query/apps HTTP/1.1\r\n\r\n". This all worked fine, what has changed in what you're evidently requiring now?
0 Kudos
mjrtoo
Binge Watcher

Re: External Control changes?

So here's the code, it was working with \r\n\r\n instead of \x0D\x0A\x0D\x0A that it appears I now have to use to get it working. And I've further edited it to test without HTTP/1.1 and that doesn't work.

STRING_FUNCTION queryServices()
{
TRACE("In queryServices Function");
tx$ = "GET /query/apps HTTP/1.1\x0D\x0A\x0D\x0A";
TRACE("tx$ = %s", tx$);
RETURN(tx$);
}

STRING_FUNCTION directAppSelect(INTEGER selApp)
{
TRACE("In directAppSelect Function");
tx$ = "POST /launch/" + service[selApp].appID + " HTTP/1.1\x0D\x0A\x0D\x0A";
currentlySelectedAppID = selApp;
TRACE("tx$ = %s", tx$);
RETURN(tx$);
}

STRING_FUNCTION keyCommand (STRING key$)
{
tx$ = "POST /" + key$ + " HTTP/1.1\x0D\x0A\x0D\x0A";
RETURN(tx$);
}
0 Kudos