I’m trying to communicate with the vera through another computer using a get command. I can send the following using a browser to the vera to control a schlage lock and it works like a charm.
However, when I change it to a get command sent to port 49451
GET /data_request?id=lu_action&outpu_format=xml&DeviceNum=12&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget&newTargetValue=1 HTTP/1.1
I get the following back from the vera
HTTP/0.0 400 Bad Request\x0D\x0ASERVER: Linux/2.4.35.4, UPnP/1.0, Portable SDK for UPnP devices/1.6.6\x0D\x0ACONTENT-LENGTH: 50\x0D\x0ACONTENT-TYPE: text/html\x0D\x0A\x0D\x0A
400 Bad Request
In fact the vera gets in a loop sending the error message over and over requring me to pull the power to reboot it.
Any help in what is wrong with my GET would be greatly apreciated.
a) A real browser sends a few more headers than you’ve indicated.
Some examples include:
Host: ...
User-Agent: ...
There are others, and some are mandatory in the HTTP/1.1 spec. Run a sniffer (WireShark, tcpdump, etc) to see what your browser is sending if you’re going to mimic in this way.
A number of people have done this successfully with [tt]wget[/tt], which is native on Linux and Mac.
b) There’s a typo in the “output_method” in the GET command shown
You’ve typed “outpu_format” instead of “output_method”. Not sure if this is what you’re truely trying to run or just a typo in this post.
Thanks. I’m not that great with a wireshark. I’ve typically used the web-sniffer web site to help me take apart an http command as it is more user friendly but the destination must be a public address on the net. I’ll put the vera on my home network with a port forward on the router to get the full header.
The devices I’ve worked with in the past haven’t requied the full http header info so I wasn’t expecting to need all of it.
You can also use Firefox Firebug plugin to see the request headers your browser is applying if you want to mimic those. There are other browser plugins that do the same, exposing the network req/response headers etc
I greatly appreciate all the help
Based on the output of the Live HTTP Plugin I’ve tried sending the following to the vera. I still get the same error.
Any other ideas?
thanks again
GET /data_request?id=lu_action&output_format=xml&DeviceNum=12&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget&newTargetValue=1 HTTP/1.1
Host: 192.168.5.133:49451
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Sat, 01 Jan 2000 00:13:16 GMT
HTTP/1.x 200 OK
Content-Length: 146
Content-Type: xml
Date: Sat, 01 Jan 2000 00:15:29 GMT
Last-Modified: Sat, 01 Jan 2000 00:15:29 GMT
Server: Linux/2.4.35.4, UPnP/1.0, Portable SDK for UPnP devices/1.6.6
X-User-Agent: redsonic
Connection: close
I’ve continued to play with this. After breaking down and digging into wireshark it looks more like everything up to the If-Modified-Since line is sent by the browser and the remainder is a reply from the vera. However, even just sending the first part from outside a browser the vera responds with an error.
Has anyone implemented a conversation with a vera from outside a browser and would be willing to share their implementation? The vera seems to be looking for a detailed ethernet conversation with acks, etc. and won’t simply accept a command in the form of a Get statement to perform an action.
After spending time reading on the details of the http protocol I am very close to having this solved.
The correct format for sending a get command to the vera for a schlage lock is:
GET /data_request?id=lu_action&output_format=xml&DeviceNum=12&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget&newTargetValue=1 HTTP/1.1 Host: 192.168.5.133:49451
without any carriage returns/linefeeds in the command string except those that I show as and
When I send this string to the vera I get a HTTP 1.1 200 OK… message and the lock will operate.
The only weird part I’m still seeing is that if I leave the connection open to the vera, after about 10 seconds I start getting HTTP/0.0 400 Bad Request messages. The vera will just continue to send them at 10 second or so intervals. Obviously when I close the connection I can no longer see if the vera is sending messages or not. I wanted to bring this up as I don’t know if this is a bug or if I still don’t have my syntax 100%.
If you can find a HTTP client library for the scripting engine your working with (or just use wget on Linux/Mac etc). Then it will take care of this for you.
In this case, given the response above, you need to close the socket connection and reopen for each request. The server responded with “Connection: close” an the client is expected to respect that.
Things will be unpredictable if you attempt to reuse that socket after the HTTP server has indicated you need to close it in their Response headers
For debugging http request you can use HTTP Analyzer and see all the headers send by the browser and then the headers send by your app. I don’t know what programming language are you using and how you’re trying to send the command so I can’t give you more advices.
Try to post more, even a part from your code so we could see what goes wrong, but as guessed said the connection that you’re making has a timeout and a max connection time.
For port 49451 we’re using the libupnp built in web server.
Best Home Automation shopping experience. Shop at Ezlo!