Your Digital Media Has Never Looked So Good

 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Question on using POST /launch/

Fri Dec 03, 2010 4:34 pm

I am trying to send the roku a POST /launch ECP command to launch a particular channel, but keep getting back a "HTTP/1.1 400 Bad Request" response. Say I wanted to launch the Netflix channel. Its my understanding that I simply plug the proper app id (as returned by query/apps) in to the launch command. For example, with Netflix (app id = 12) I send the command:

POST /launch/12 HTTP/1.1 (with the appropriate cr lf following)

For a basic launch of this channel there really aren't any parameters to also put in. Or are there? Am I missing something? I get similar failed responses when trying to launch, say, Vimeo or others.
 
User avatar
RokuChris
Posts: 1166
Joined: Mon Aug 30, 2010 1:45 pm

Re: Question on using POST /launch/

Fri Dec 03, 2010 4:47 pm

Sounds like you are on the right track. The launch command does not require any parameters. I can successfully launch the Netflix channel using this command from a terminal and substituting the IP address of a Roku:

curl -d "" "http://xxx.xxx.xxx.xxx:8060/launch/12"
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Question on using POST /launch/

Fri Dec 03, 2010 4:53 pm

That syntax works fine for me. Are you specifying the HOST header with the appropriate 8060 port?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Re: Question on using POST /launch/

Fri Dec 03, 2010 5:12 pm

Thanks for the responses.

I'm doing a send to the same address/port (port being 8060) that I use for, say, a GET /query/apps or a POST /keypress (which work). The exact data I send is as in my first post, namely (for netflix):

"POST /launch/12 HTTP/1.1" (without the quotes and with two appended carriage return line feeds)

TheEndless, are you saying I need to literally include (append) a "Host: xxx.xxx.xxx.xxx:8060" on to the post data sent?
 
User avatar
RokuMarkn
Roku Engineering
Posts: 1581
Joined: Mon Jun 09, 2008 9:20 am

Re: Question on using POST /launch/

Fri Dec 03, 2010 5:22 pm

Yes, the HTTP protocol requires a Host header. You probably also need a Content-Length:0 header.

--Mark
 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Re: Question on using POST /launch/

Fri Dec 03, 2010 5:27 pm

Ah, so I assume that this is because HTTP 1.1 is being used as opposed to 1.0? But why then is it that if I do a POST for something like the KEYPRESS I have no problem withno header supplied?

Note: In the SDK example program to launch an app they provide no host header, but they use HTTP 1.0.
 
User avatar
RokuKevin
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: Question on using POST /launch/

Fri Dec 03, 2010 5:38 pm

Here's an example to launch netflix.... insert your ipaddress in the line below:

echo -e "POST /launch/12 HTTP/1.1\r\n\r\n" | ncat 192.168.1.120 8060

--Kevin
 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Re: Question on using POST /launch/

Fri Dec 03, 2010 5:50 pm

RokuKevin,

That may work with ncat, but when (just) the line POST /launch/12 HTTP/1.1\r\n\r\n is sent programatically I get the "400 Bad Request" mentioned initially. I have not try it yet, but it may well be as TheEndless has suggested. With HTTP 1.1 (vs 1.0) the addtional header(s) are needed, at least the HOST: . I will try it and see. If it works then it will be puzzling why something like the POST keypress works without the header. That might mean there is something improper in the ROKU firmware.

I'll post what I find...
 
User avatar
RokuMarkn
Roku Engineering
Posts: 1581
Joined: Mon Jun 09, 2008 9:20 am

Re: Question on using POST /launch/

Fri Dec 03, 2010 6:59 pm

Sorry for the confusion -- it appears that no headers are necessary with either the keypress or launch commands.
The string you are sending should work fine. Make sure you don't have any extraneous characters queued up in the socket (like from a previous command) before you send your command. That could cause the 400 error you're seeing.

--Mark
 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Re: Question on using POST /launch/

Sat Dec 04, 2010 5:44 pm

Well for what it is worth...

When I had been trying to issue a POST launch (HTTP 1.1, not 1.0) without any headers I had no success. I confirmed (I swear) the content of the command text was fine. However, when I now add an additional Host: header (ie. Host: xxxx.xxxx.xxxx.xxxx:8060) the command(s) work and the channels launch. Makes sense, since the HTTP 1.1 spec does say the header (at least the host) is required.

My thanks to TheEndless for putting me on the right track!
 
User avatar
RokuMarkn
Roku Engineering
Posts: 1581
Joined: Mon Jun 09, 2008 9:20 am

Re: Question on using POST /launch/

Sat Dec 04, 2010 6:33 pm

Hm, well it works for me without headers. I do "telnet 192.168.1.xxx 8060" and then enter "POST /launch/12 HTTP/1.1" followed by two newlines, and I get a 200 OK response. But there's certainly no harm in adhering to the spec by sending the Host header.

--Mark
 
tdurrant420
Posts: 29
Joined: Tue Feb 23, 2010 11:46 pm

Re: Question on using POST /launch/

Sat Dec 04, 2010 6:47 pm

Paps,

what app are using for the POST? (hyperterminal, c, c#, C++ java etc etc etc, mac, pc, linux etc etc)
 
paps33
Topic Author
Posts: 14
Joined: Fri Dec 03, 2010 4:12 pm

Re: Question on using POST /launch/

Mon Dec 06, 2010 9:01 am

tdurrant420,

I've been using both VB and even AutoIt, from/on a PC (XP and Vista). I should note that I also compiled and ran the sample SDK program related to ECP (it uses HTTP 1.0). One thing I noticed with it was that where it does a get/apps the response contains no apps. It gets the header part of the repsonse message back fine, and shows an appropriate number of bytes that should be in the message body. But there is no message body (ie. there's the header , but no data).

A strange thing is that I had not been using the additional header in POSTs (or GETs). Keypress seemed to work without it. Get/apps had random problems, sometimes there'd be a usable response - sometimes not. But when I got to trying to launch apps nothing worked until I added the additional HOST: header. Now I've gone back and added the header to eveything I do (except the SSDP Discovery of course). That's seems to have produced reliable exchanges.
 
User avatar
RokuKevin
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: Question on using POST /launch/

Mon Dec 06, 2010 10:28 am

The Roku shouldn't be requiring the Host header, but maybe your client libraries do??

The sample app should not be requiring the header either. We tested it on Linux and Windows.

--Kevin
 
wbmurray
Posts: 15
Joined: Fri May 21, 2010 11:01 am

Re: Question on using POST /launch/

Sun Dec 12, 2010 9:31 am

For my Philips pronto 9400 remote here is the script that I use. I have a page on my remote that shows my "favorites", In each button I call the function:

roku_launch(11); //where the value is the id of the channel.

In the activities page I store the actual function :

function roku_launch(channel) {
//System.print(channel);
var url = CF.widget("aURL","PARAMETERS").label;
var timeout = CF.widget("aTIMEOUT","PARAMETERS").label;
var socket = new TCPSocket(true);
socket.connect(url, 8060, timeout);
socket.write("POST /launch/"+channel+ " HTTP/1.1\r\n\r\n");
socket.close();
}


This works great.

Bill

Who is online

Users browsing this forum: No registered users and 6 guests