简体   繁体   中英

How to send http request via ssdp in typescript

I am following this tutorial: https://sdkdocs.roku.com/display/sdkdoc/External+Control+API ...trying to grab a list of devices via ssdp / http get.

  let query: string = "M-SEARCH * HTTP/1.1\\r\\n" + "HOST: 239.255.255.250:1900\\r\\n" + "MAN: \\"ssdp:discover\\"\\r\\n" + "ST: roku: ecp\\r\\n\\r\\n"; this.http .get(query) .map(res => res.json()) .subscribe( (data) => this.devices = data, (err) => this.error = err); 

... but I'm getting a 404 error (also, localhost is being appended to the string):

 Failed to load resource: the server responded with a status of 404 (Not Found) 

 http://localhost:52125/M-SEARCH%20*%20HTTP/1.1HOST:%20239.255.255.250:1900MAN:%20%22ssdp:discover%22ST:%20roku:%20ecp 

SSDP uses HTTPU or HTTP over UDP. Node's HTTP client only sends data over TCP. You'll need to use a udp socket to send this manually and listen for data, or use a pre-existing library such as node-ssdp .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM