如何通过打字稿中的SSDP发送HTTP请求



我正在遵循本教程:https://sdkdocs.roku.com/display/sdkdoc/external Control Papi...试图通过SSDP/HTTP GET获取设备列表。

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

...但是我遇到了404错误(也将Localhost附加到字符串上(:

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在UDP上使用HTTPU或HTTP。Node的HTTP客户端仅通过TCP发送数据。您需要使用UDP套接字手动发送此数据并侦听数据,或使用诸如node-ssdp的库。

相关内容

  • 没有找到相关文章