I’m experimenting with the Chromecast API v1 and have implemented device discovery via SSDP, but I’m unable to retrieve the device configuration XML data via HTTP GET. I’ve seen a couple of similar posts regarding SmartApp GET requests that never receive a response, and I’m hoping to pin down the exact cause.
So far, I’ve convinced myself that it has something to do with the response headers.
Here’s an example from a GET request sent to a Sony STR-DN1040. This was done from telnet, and my SmartApp is able to receive the response via a location listener.
GET /description.xml HTTP/1.1
HTTP/1.1 200 OK
X-AV-Server-Info: av=“5.0”; cn=“Sony Corporation”; mn=“STR-DN1040”; mv="1.00"
Meanwhile, here is what I get from the Chromecast. Works via telnet, but the hub sees nothing. Maybe the hub is rejecting the response based on the Content-Type or the lower-case attribute names?
GET /ssdp/device-desc.xml HTTP/1.1
HTTP/1.1 200 OK
On the SmartApp side of things, my code follows the pattern used by various other SSDP-based SmartApps that retrieve XML data (ex. MediaRenderer). It looks like this:
def action = new physicalgraph.device.HubAction(
"""GET $ssdpPath HTTP/1.1\r\nHOST: $ip\r\n\r\n""",
Any ideas (or commiseration) appreciated.
Afaik, hub does not parse http headers. It does have a limit on the response size. How big is the Chromecast response?
The Chromecast response is smaller than the Sony AVR response at 1091 bytes versus 5020 bytes.
I think my next step will be to set up a server with a controlled response and make it look more and more like the AVR response until the hub decides to recognize it. Will update with results.
Not sure if this the problem, but it looks like your HubAction string isn’t formatted correctly, since it is looking for two new lines after the IP address. Perhaps changing it to this would work:
“”“GET $ssdpPath HTTP/1.1\r\nHOST: $ip\r\n”""
After some experimentation, it turns out the hub won’t parse responses from requests sent to port 8008. If I attempt to send any response from a demo server running on port 8008, the response will be dropped; however, changing to port 8080 resolves the issue and the response comes through to my SmartApp.
Of course, since the Chromecast hardware only serves on port 8008, this knowledge isn’t very helpful for me; however, maybe some friendly SmartThings engineer will see this thread and make a patch.
Edit: To clarify, if I run a server on port 8008, the server sees the HTTP request from the hub but the hub drops the response. If I change the port to 8080, the hub handles the response correctly.
I seem to have the same problem, but with port 8000. It actually worked without any issues, but i deleted the device and after I added it again with the same device handler, it doesn’t work anymore. It works for all other ports I have tried, except the port 8000 that I was using before i deleted the device.
Only thing I can think of is that deleting the device somehow caused Smart Hub to ignore the responses from the port (8000) it was using at the time i deleted it. I have no idea why this happened, but I assume Alanv had the same problem with port 8008 (I tried and I get a response from Chromecast on port 8008). Does anyone have any ideas what the problem could be or how to resolve it?
I’m using this device handler https://github.com/KristopherKubicki/device-type.http-ping/blob/master/http-ping.devicetype.groovy to check if my Samsung TV is on or off (I modified the device handler a bit to make it work on V2 hub).
im lloking at this, do you have the updated v2 code?