我正在尝试在没有互联网连接的情况下在用 aiortc 用 Python 编写的相机服务和用 javascript 编写的 Web 前端之间创建 RTCPeerConnection。
camera-service 访问 usb-camera 并为其他两个服务提供流。对于用javascript编写的前端和用python编写的图像分类服务。所有这些服务都在本地主机上的不同端口上运行。我需要在没有互联网连接的情况下完成这项工作。
两个python服务之间的RTCPeerConnection在没有互联网连接的情况下工作,但前端和camera-service之间的连接不起作用。
如果没有互联网连接,相机服务的 ICEConnectionState 永远不会完成,只是检查,所以我认为这是某种问题。
要重现此问题,只需尝试使用 aiortc ( https://github.com/aiortc/aiortc/tree/master/examples/webcam )的网络摄像头示例,无论是否有互联网连接。
javascript中的前端
var pc = new RTCPeerConnection({
"iceServers": []
});
//start the negotiating process with camera-service(running on localhost:8080)
function negotiate() {
pc.addTransceiver('video', {direction: 'recvonly'});
return pc.createOffer().then(function(offer) {
return pc.setLocalDescription(offer);
}).then(function() {
// wait for ICE gathering to complete
return new Promise(function(resolve) {
if (pc.iceGatheringState === 'complete') {
resolve();
} else {
function checkState() {
if (pc.iceGatheringState === 'complete') …Run Code Online (Sandbox Code Playgroud)