【问题标题】:connection issues webRTC App. works only local, not mobile连接问题 webRTC 应用程序。只能在本地工作,不能在移动设备上工作
【发布时间】:2020-05-12 11:37:04
【问题描述】:

非常感谢有关此问题的一些帮助。不知道如何继续。

正在尝试制作一个 webRTC 应用程序。信令服务器是 Node.js 上的 WebSocket。由于某种原因无法与手机建立连接。使用 - 或 - 尝试使用 coturn。我不确定问题是客户端还是服务器端@coturn 中继服务器。

在我的例子中,调用者是调节器路由器后面的电脑,被调用者是手机,turn 和 websocket 是公共的。

///CLIENTS BOTH CALLER and CALLEE
async function createPeerConnection() {
  log("Setting up a connection...");
  const iceConfig = {
    "iceServers": [{
      "urls": "stun:mycoturn.online:5349",
      "username": "guest",
      "credential": "password"
    }
    ,{
      "urls": "turn:mycoturn.online:5349",
      "username": "guest",
      "credential": "password"
    }]
  }

  myPeerConnection = new RTCPeerConnection(
  // {
  //   iceServers: [    
  //     {
  //       urls: "stun:stun1.l.google.com:19302",
  //       username: "",
  //       credential: ""
  //     }
  //   ]
  // }
   iceConfig
  );

  myPeerConnection.onicecandidate = handleICECandidateEvent;
  myPeerConnection.oniceconnectionstatechange = handleICEConnectionStateChangeEvent;
  myPeerConnection.onicegatheringstatechange = handleICEGatheringStateChangeEvent;
  myPeerConnection.onsignalingstatechange = handleSignalingStateChangeEvent;
  myPeerConnection.onnegotiationneeded = handleNegotiationNeededEvent;
  myPeerConnection.ontrack = handleTrackEvent;
}

[... Some code]

function handleICECandidateEvent(event) {
  // if (event.candidate) {
    log("*** Outgoing ICE candidate: ");
    sendToServer({
      type: "new-ice-candidate",
      target: targetId,
      candidate: event.candidate,
      id: clientID
    });
  // }
}

async function handleNewICECandidateMsg(msg) {
  var candidate = msg.candidate;

  log("*** Adding received ICE candidate: " + JSON.stringify(candidate));
  try {
    await myPeerConnection.addIceCandidate(candidate)
  } catch(err) {
    reportError(err);
  }
}

调用者和被调用者最后发送的候选者都是 null(candidate:null),它也是由两者添加的 addIceCandidate(candidate)

在被调用者得到候选事件“candidate:null”后,被调用者得到“handleICEConnectionStateChangeEvent: failed” 最后我在控制台中收到此错误消息:

ICE 失败,您的 TURN 服务器似乎已损坏,有关详细信息,请参阅 about:webrtc

这是我通过公共 google stun 服务器以及我的 coturn stun/turn 收到的最后且唯一的错误消息。

我应该提供哪些有意义的信息? 我应该在哪里搜索错误?真的不知道。

非常感谢提前 干杯

【问题讨论】:

    标签: webrtc coturn


    【解决方案1】:

    首先要做的事情。

    你必须检查你的回合服务器(coTURN)是否运行良好。

    如需检查,请转至Trickle ICE

    1. 移除默认的 google stun 服务器,并添加您的转向服务器信息。

    2. 在 ICE 选项部分选择继电器选项。

    3. 点击“收集候选人”按钮。

    如果你能得到具有'rtp relay'组件类型的候选人,你的轮到服务器运行良好。

    因此,如果没有候选人,你必须修复你的回合服务器。

    如果没有,您必须修复您的信令服务器或客户端。

    【讨论】:

    • 感谢您指出删除默认值。我会尽快继续处理这个问题。
    • 问题确实出在我的服务器上。 >Pion 转服务器
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多