我正在开发一个带有摄像头实时流媒体页面的 Angular 网络应用程序。 通过 rtsp 代理使用 JSMPEG 库在 Canvas 标签中显示流。
我的申请与我在这个问题中描述的类似:Not able to Show live camera RTSP streaming with Angular
负责尖叫的 Typescript 代码是通过启动 websocket 请求的 JSMPEG 完成的:
new JSMpeg.Player('ws://my_ip:9999', {
canvas: this.streamingcanvas.nativeElement, autoplay: true, audio: false, loop: true
})
我使用这个命令执行了我的应用程序:
ng serve --host 0.0.0.0 --disable-host-check --proxy-config proxy.config.json
我的应用程序和直播工作正常。
现在我想通过 https 执行我的应用程序。所以我用 openssl 生成了证书,然后我使用以下命令执行了我的应用程序:
ng serve --host 0.0.0.0 --disable-host-check --proxy-config proxy.config.json --ssl true --ssl-cert /home/ubuntu/ssl/angular-selfsigned.crt --ssl-key /home/ubuntu/ssl/angular-selfsigned.key
结果是我可以使用https成功访问我的网页,但是直播不工作。
我检查了 firefox 控制台,我发现了以下错误:
注意:灰色区域为my_ip地址
我检查了网络选项卡,我找不到任何流媒体代理请求 ws://my_ip:9999
这个问题的主要原因是什么?我该如何解决?
最佳答案
尝试使用“wss://my_ip:9999”而不是“ws://my_ip:9999”
关于javascript - Angular 超过 https : websocket request not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59386918/