0

re: https://developer.sony.com/develop/audio-control-api/hardware-overview/discovery-process

Hello. I have an APAC region Sony STR-DN1080 AVR. I am able to control said AVR via the API just fine. I just cannot discover supported Sony devices using SSDP.

It seems that the AVR is periodically advertising itself to the network via UDP, but it is not responding to any multicast requests using the format described in the docs.

The Web API service does not even reply when I replace the "ST: ...." line with ST: upnp:rootdevice or ST: ssdp:all. Other devices on my network do reply, but not the Web API service. The built-in UPnP/DLNA service does respond however.

Here is my packet:

String msg = "M-SEARCH * HTTP/1.1\r\n" +
    "HOST: 239.255.255.250:1900\r\n" +
    "MAN: \"ssdp:discover\"\r\n" +
    "MX: 1\r\n" +
    "ST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\n" +
    "USER-AGENT: me\r\n" +
    "\r\n" ;

Is there something I am missing? Thanks in advance.

grolschie
  • 2,163
  • 2
  • 12
  • 29
  • From this information I can't se anything obvious wrong. Then I do the same using Python this has worked: SSDP_BROADCAST_ADDR = '239.255.255.250' . SSDP_BROADCAST_PORT = 1900 . SSDP_BROADCAST_PARAMS = [ 'M-SEARCH * HTTP/1.1', "HOST: {0}:{1}".format(SSDP_BROADCAST_ADDR, SSDP_BROADCAST_PORT), 'MAN: "ssdp:discover"', 'MX: 10', 'ST: ssdp:all', '', ''] . SSDP_BROADCAST_MSG = '\r\n'.join(SSDP_BROADCAST_PARAMS) . – David - Sony Oct 31 '18 at 14:53
  • Thanks. Are you using the APAC region model? – grolschie Oct 31 '18 at 18:51
  • How long should I set the socket timeout to give the AVR a chance to reply? I have set it to 10 seconds. – grolschie Oct 31 '18 at 18:53
  • Just to clarify. My understanding is that there are 2 ways of sending a Multicast packet and receiving a Unicast reply: One is sending via a DatagramSocket to the broadcast address and listening on the same socket. The other would be sending via a MulticastSocket, leaving the group, closing the socket, and then opening a DatagramSocket on the same port (1900) for listening. The first method worked for me for getting responses from my other devices. The second, I couldn't get working without socket bind errors. – grolschie Oct 31 '18 at 21:08
  • I using the first method. I'm not 100% sure but I think MulticastSocket is a Java class then extends the normal DatagramSocket with group functionality, so it sounds strange to me that you should have to close that socket to open another. I have tested with both EU and US models (should be the the same as APAC), then it response it is with in seconds. The device can also be very sensitive to the right message format. If you have the possibility try to use wireshark to sniff the network to see how the packages looks, and if possible find a working implementation to sniff. – David - Sony Oct 31 '18 at 22:17
  • see https://pastebin.com/ekPS5i80 for how my M-SEARCH message looks like then captured by WireShark – David - Sony Oct 31 '18 at 22:47
  • One more thing the device will answer back on the same port as the M-SEARCH was sent from, so opening and closing the socket will never work. App sends M-SEARCH from port 51157 -> port 1900 Device sends from port 12345 -> port 51157. – David - Sony Oct 31 '18 at 23:11
  • Thank you the information. Wireshark doesn't seem to capture any ssdp packets on my Windows 10 notebook's wifi card. It's in promiscuous mode. My packet looks pretty much the same - although in the OP I had missed the double-quotes in the MAN line. I am presuming that the AVR doesn't mind multicast over wifi, since it broadcasts an alive message periodically. – grolschie Nov 01 '18 at 03:13
  • Ok, progress. I needed a blank line at the end, i.e. "\r\n\r\n" instead of "\r\n", for the AVR to respond. It responds to Search Targets of "ssdp:all", "upnp:rootdevice" and "urn:dial-multiscreen-org:device:dial:1". But it doesn't respond to: "urn:schemas-sony-com:service:ScalarWebAPI:1". Strange? – grolschie Nov 01 '18 at 08:10
  • My AVR's http://{IP-Address}:8008/ssdp/device-desc.xml doesn't contain "urn:schemas-sony-com:service:ScalarWebAPI:1". Does yours? Here is mine: https://pastebin.com/3he3zQgF – grolschie Nov 01 '18 at 09:22
  • Don't have access to my DN1080 right now but that device address looks strange. If I remember correctly for it is http://{IP-Address}:61000/dd.xml for my DN1080, and for my HT-ZF9 that I have access to now it is http://{IP-Address}:54380/MediaRenderer_HT-ZF9.xml. I think you are looking at the wrong response DN1080 will send 3 responses to a M-SEARCH (MediaServer, MediaRenderer and Dial) it is the MediaRenderer that you are interested in, the message you pasted is the from the Dial response. – David - Sony Nov 01 '18 at 13:30
  • Tip: I'm using https://play.google.com/store/apps/details?id=com.tjjang.upnptool in my Android phone to view and quickly find upnp devices in the current wifi network. – David - Sony Nov 01 '18 at 13:39
  • Thanks for that. It appears that it is indeed DIAL (labeled by the upnptool as a Chromecast device) that is responding to my broadcast, but no other services. That upnptool shows that there are 7 other services. But only this one is replying to my broadcast. – grolschie Nov 01 '18 at 18:10
  • I'm stumped. I can get a response from the built-in Chromecast in the AVR, modem, WD My Cloud, TV, Xbox One, but not the other services in the STR-DN1080. I've tried many permutations of the values for the string. upnptool can find all the services though... weird. – grolschie Nov 01 '18 at 23:34
  • David, are you familiar with Android programming in Java for this AVR? If so, can I message you the code snippet please? – grolschie Nov 06 '18 at 21:47
  • David, do you have an opinion on this: the Legal Information says that the API is covered by a CC No Derivatives license. That kinda means we cannot grab any code/JSON samples from your online API docs (such as the above string which I have cut'n'pasted and modified) to use in our apps right? ref: https://developer.sony.com/develop/audio-control-api/legal-information on this? – grolschie Jan 25 '19 at 00:57
  • Maybe license the JSON examples under the Apache 2.0 license? – grolschie Jan 25 '19 at 03:40
  • @David-Sony Any chance of a snippet of your Python code for the discovery process please? Maybe I can see if you're doing something different to me. – grolschie Dec 04 '19 at 03:47

1 Answers1

0

Solution. I couldn't get the required response from the Sony STR-DN1080 with the specified M-SEARCH broadcast no matter how I tried. So instead, this is what I did:

  1. use the tag ST: ssdp:all\r\n in the M-SEARCH broadcast.
String msg = "M-SEARCH * HTTP/1.1\r\n" +
    "HOST: 239.255.255.250:1900\r\n" +
    "MAN: \"ssdp:discover\"\r\n" +
    "MX: 1\r\n" +
    "ST: ssdp:all\r\n" +
    "\r\n" ;
  1. build a Set of the IP addresses of all replying devices.
  2. search each device in Set for the existence of this file: {ip address}:8008/ssdp/device-desc.xml.
  3. scan through each line of that XML file for string "STR-DN1080".

It's not where I wanted to end up, but it works.

grolschie
  • 2,163
  • 2
  • 12
  • 29