IP摄像机翻译无法通过aiortc和STUN服务器工作

2024-06-11 22:18:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在玩aiortc演示(https://github.com/aiortc/aiortc/tree/main/examples/server),从网页上的IP摄像头进行翻译。它在我可以访问的一台服务器上工作,但在另一台服务器上不工作。后者在docker内部。 有时我在client.js on中遇到客户端错误

}).then(function(response) {
        return response.json();       // - not a JSON object
    }).then(function(answer) {
        document.getElementById('answer-sdp').textContent = answer.sdp;
        return pc.setRemoteDescription(answer); 

有时是停止下降。JSON是在server.py中生成的,带有

return web.Response(
        content_type="application/json",
        text=json.dumps(
            {"sdp": pc.localDescription.sdp, "type": pc.localDescription.type}
        ),
    )

我比较了两台服务器,它们看起来都不错,但在坏掉的服务器上,它包含的候选记录更少

无论如何。我在服务器日志中看到的是,当一切正常时(左侧,“协议(0)”和“协议(1)”)会对一个协议尝试几种协议, enter image description here

更多信息: enter image description here

最后陈述。连接->;State.CONNECTED(顶部)与->;State.FAILED: enter image description here

因此,我怀疑第一台服务器上有一些python模块提供了附加协议。他们的设置非常不同,但aiortc的版本是相同的。我可以在坏掉的服务器上更改一些已安装的模块,但不是全部。那么我该怎么做才能解决这个问题呢?也许应该做一些额外的网络设置

Python 3.7.10/3.7.7 enter image description here


Tags: answer服务器jsonsdp协议returnserverresponse