0

我是 WebRTC 和 Websockets 世界的新手。我尝试使用Agora Web SDK NG实现 1 对 1 视频通话,并且在同一网络上的两台设备(PC 和 Android 移动设备)上一切正常。一旦我的智能手机连接了移动数据,我就无法再加入通话,尽管它仍然可以同时在连接到路由器的 PC 上运行。

这是用于在我的 Angular 服务中启动调用的函数:

async startCall(userId: string) {
    this.callStatus$.next('connecting');
    this.rtc.client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" });

    // * Listen to new users joining the channel
    this.rtc.client.on('user-published', async (user, mediaType) => {
      console.log('remote user published');
      // Subscribe to a remote user.
      await this.rtc.client.subscribe(user, mediaType);
      console.log('subscribe to remote user success');
      this.callStatus$.next('online');

      // If the subscribed track is video.
      if (mediaType === 'video') {
        // Get `RemoteVideoTrack` in the `user` object.
        const remoteVideoTrack = user.videoTrack;

        // Play the remote video track.
        // Pass the DIV container and the SDK dynamically creates a player in the container for playing the remote video track.
        // remoteVideoTrack.play(playerContainer);

        // Or just pass the ID of the DIV container.
        remoteVideoTrack.play('video-player');
      }

      // If the subscribed track is audio.
      if (mediaType === 'audio') {
        // Get `RemoteAudioTrack` in the `user` object.
        const remoteAudioTrack = user.audioTrack;
        // Play the audio track. No need to pass any DOM element.
        remoteAudioTrack.play();
      }
    });

    // * Listening for users leaving the channel
    this.rtc.client.on('user-unpublished', user => {
      console.log('remote user unpublished');
      this.callStatus$.next('waiting');
    });

    this.rtc.client.on('exception', (event) => console.error('RTC CLIENT ERROR ', event));

    // * Joining the channel
    try {
      // Join channel
      await this.rtc.client.join(agoraConfig.appId, agoraConfig.channel, agoraConfig.token, userId);
      // Create an audio track from the audio sampled by a microphone.
      this.rtc.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
      // Create a video track from the video captured by a camera.
      this.rtc.localVideoTrack = await AgoraRTC.createCameraVideoTrack({ facingMode: 'user' });
      // Publish the local audio and video tracks to the channel.
      // ---------------- THE STATEMENT BELOW IS WHERE IT HANGS ---------------------
      await this.rtc.client.publish([this.rtc.localAudioTrack, this.rtc.localVideoTrack]);
      // ----------------------------------------------------------------------------

      // If peer already connected set status to online otherwise set as waiting
      if (this.rtc.client.remoteUsers.length)
        this.callStatus$.next('online');
      else
        this.callStatus$.next('waiting');

      console.log('self join and publish success !');
    } catch (e) {
      this.callStatus$.error('join-error');
      console.error(e);
    }
  }

它给出了各种错误,并不断尝试在上面标有注释的语句上重新发布流。以下是导航到页面时的 Web 控制台日志,然后尝试从我的移动设备加入呼叫:

20:41:29.528 20:41:29:528 Agora-SDK [INFO]: browser compatibility {"getDisplayMedia":false,"getStreamFromExtension":false,"supportUnifiedPlan":true,"supportMinBitrate":false,"supportSetRtpSenderParameters":true,"supportDualStream":true,"webAudioMediaStreamDest":true,"supportReplaceTrack":true,"supportWebGL":true,"webAudioWithAEC":true,"supportRequestFrame":false,"supportShareAudio":false} {"name":"Firefox","version":"80","os":"Android"} AgoraRTC_N-production.js:375:233
20:41:29.831 Angular is running in development mode. Call enableProdMode() to enable production mode. core.js:26833
20:41:33.697 CALLSTATUS connecting video-call.component.ts:25:33
20:41:33.706 20:41:33:706 Agora-SDK [INFO]: [client-d337a] Initializing AgoraRTC client v4.1.0 build: v4.1.0-0-g64d4440(9/4/2020, 5:57:23 PM), mode: rtc, codec: vp8 AgoraRTC_N-production.js:375:233
20:41:33.715 20:41:33:715 Agora-SDK [INFO]: [client-d337a] start join channel cataphract-channel AgoraRTC_N-production.js:375:233
20:41:33.719 20:41:33:719 Agora-SDK [INFO]: [client-d337a] connection state change: DISCONNECTED -> CONNECTING AgoraRTC_N-production.js:375:233
20:41:34.450 20:41:34:450 Agora-SDK [DEBUG]: getUserAccount Success h2uR9JUyyUcu3YwywmxrhHguRwJ2 => 1000000001 AgoraRTC_N-production.js:375:113
20:41:34.453 20:41:34:454 Agora-SDK [DEBUG]: [client-d337a] Connect to choose_server: https://webrtc2-ap-web-1.agora.io/api/v1 AgoraRTC_N-production.js:375:113
20:41:34.459 20:41:34:459 Agora-SDK [DEBUG]: [client-d337a] Connect to choose_server: https://webrtc2-ap-web-2.agoraio.cn/api/v1 AgoraRTC_N-production.js:375:113
20:41:35.074 20:41:35:74 Agora-SDK [DEBUG]: [gateway-client-d337a] start connect, url: wss://128-1-77-51.edge.agora.io:5888 AgoraRTC_N-production.js:375:113
20:41:35.395 20:41:35:395 Agora-SDK [DEBUG]: [gateway-client-d337a] websockect opened: wss://128-1-77-51.edge.agora.io:5888 AgoraRTC_N-production.js:375:113
20:41:35.536 20:41:35:536 Agora-SDK [INFO]: [client-d337a] connection state change: CONNECTING -> CONNECTED AgoraRTC_N-production.js:375:233
20:41:35.578 20:41:35:579 Agora-SDK [DEBUG]: [client-d337a] Connected to gateway server AgoraRTC_N-production.js:375:113
20:41:35.589 20:41:35:589 Agora-SDK [INFO]: [client-d337a] Joining channel success: cataphract-channel AgoraRTC_N-production.js:375:233
20:41:35.602 20:41:35:602 Agora-SDK [INFO]: start create microphone audio track with config {} trackId track-34f6a29f AgoraRTC_N-production.js:375:233
20:41:35.608 20:41:35:609 Agora-SDK [DEBUG]: [track-34f6a29f] GetUserMedia {"audio":{}} AgoraRTC_N-production.js:375:113
20:41:38.937 20:41:38:936 Agora-SDK [INFO]: create microphone audio track success, trackId: track-34f6a29f AgoraRTC_N-production.js:375:233
20:41:38.948 20:41:38:948 Agora-SDK [INFO]: start create camera video track with config {"facingMode":"user"} trackId track-5b4971e3 AgoraRTC_N-production.js:375:233
20:41:38.951 20:41:38:951 Agora-SDK [DEBUG]: [track-5b4971e3] GetUserMedia {"video":{"facingMode":"user"}} AgoraRTC_N-production.js:375:113
20:41:40.209 20:41:40:209 Agora-SDK [INFO]: create camera video success, trackId: track-5b4971e3 AgoraRTC_N-production.js:375:233
20:41:40.222 20:41:40:222 Agora-SDK [INFO]: [client-d337a] Publishing tracks, id track-34f6a29f ,track-5b4971e3 AgoraRTC_N-production.js:375:233
20:41:40.240 20:41:40:239 Agora-SDK [DEBUG]: [client-d337a] publish high stream AgoraRTC_N-production.js:375:113
20:41:40.249 WebRTC: Using more than two STUN/TURN servers slows down discovery AgoraRTC_N-production.js:705
20:41:40.268 20:41:40:268 Agora-SDK [DEBUG]: [client-d337a-pub-1] add audio track to pc AgoraRTC_N-production.js:375:113
20:41:40.275 20:41:40:275 Agora-SDK [DEBUG]: [client-d337a-pub-1] add video track to pc AgoraRTC_N-production.js:375:113
20:41:40.281 20:41:40:282 Agora-SDK [DEBUG]: [client-d337a-pub-1] set pc rtp sender 
Object { maxBitrate: undefined }
 balanced AgoraRTC_N-production.js:375:113
20:41:40.315 20:41:40:315 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:41:40.471 20:41:40:471 Agora-SDK [DEBUG]: [client-d337a-pub-1] set answer success AgoraRTC_N-production.js:375:113
20:41:40.514 20:41:40:515 Agora-SDK [INFO]: [client-d337a-pub-1] ice-state: pub p2p checking AgoraRTC_N-production.js:375:233
20:41:40.517 20:41:40:518 Agora-SDK [INFO]: [client-d337a-pub-1] connection-state: pub p2p connecting AgoraRTC_N-production.js:375:233
20:41:44.724 20:41:44:724 Agora-SDK [DEBUG]: [client-d337a] receive exception msg, code: 2003, msg: SEND_AUDIO_BITRATE_TOO_LOW, uid: h2uR9JUyyUcu3YwywmxrhHguRwJ2 AgoraRTC_N-production.js:375:113
20:41:44.726
RTC CLIENT ERROR  
Object { code: 2003, msg: "SEND_AUDIO_BITRATE_TOO_LOW", uid: "h2uR9JUyyUcu3YwywmxrhHguRwJ2" }
video-call.service.ts:76:55
20:41:44.734 20:41:44:735 Agora-SDK [DEBUG]: [client-d337a] receive exception msg, code: 1003, msg: SEND_VIDEO_BITRATE_TOO_LOW, uid: h2uR9JUyyUcu3YwywmxrhHguRwJ2 AgoraRTC_N-production.js:375:113
20:41:44.736
RTC CLIENT ERROR  
Object { code: 1003, msg: "SEND_VIDEO_BITRATE_TOO_LOW", uid: "h2uR9JUyyUcu3YwywmxrhHguRwJ2" }
video-call.service.ts:76:55
20:41:45.261 20:41:45:261 Agora-SDK [DEBUG]: [pc-1] onicecandidate timeout, local candidate count 12 AgoraRTC_N-production.js:375:113
20:41:45.538 WebRTC: ICE failed, see about:webrtc for more details
20:41:45.540 20:41:45:540 Agora-SDK [INFO]: [client-d337a-pub-1] ice-state: pub p2p failed AgoraRTC_N-production.js:375:233
20:41:45.555 20:41:45:556 Agora-SDK [DEBUG]: [client-d337a-pub-1] start reconnect pc AgoraRTC_N-production.js:375:113
20:41:45.642 WebRTC: Using more than two STUN/TURN servers slows down discovery AgoraRTC_N-production.js:705
20:41:45.679 20:41:45:679 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:41:45.763 20:41:45:763 Agora-SDK [DEBUG]: [gateway-client-d337a] websocket close wss://128-1-77-51.edge.agora.io:5888/, code: 1006, reason: , current mode: retry AgoraRTC_N-production.js:375:113
20:41:45.768 20:41:45:768 Agora-SDK [INFO]: [client-d337a] connection state change: CONNECTED -> RECONNECTING AgoraRTC_N-production.js:375:233
20:41:45.772 20:41:45:772 Agora-SDK [DEBUG]: [client-d337a] ready to reconnect high stream AgoraRTC_N-production.js:375:113
20:41:45.778 rec retry true AgoraRTC_N-production.js:604:396
20:41:45.783 20:41:45:783 Agora-SDK [DEBUG]: [client-d337a] renewSession D2A8F6FA0344A873B981D670DBC81AEB => F2EEDD3DC589682734C25868E718D468 AgoraRTC_N-production.js:375:113
20:41:45.786 20:41:45:786 Agora-SDK [DEBUG]: [client-d337a] ready to reconnect high stream AgoraRTC_N-production.js:375:113
20:41:45.790 20:41:45:790 Agora-SDK [DEBUG]: [gateway-client-d337a] wait 500ms to reconnect websocket, mode: tryNext AgoraRTC_N-production.js:375:113
20:41:45.794
20:41:45:794 Agora-SDK [ERROR]: AgoraRTCError WS_ABORT: type: publish AgoraRTC_N-production.js:375:450
20:41:46.296 20:41:46:296 Agora-SDK [DEBUG]: [gateway-client-d337a] websocket url length: 3 current index: 1 AgoraRTC_N-production.js:375:113
20:41:46.303 20:41:46:303 Agora-SDK [DEBUG]: [gateway-client-d337a] start connect, url: wss://193-118-58-26.edge.agoraio.cn:5889 AgoraRTC_N-production.js:375:113
20:41:46.823 20:41:46:823 Agora-SDK [DEBUG]: [gateway-client-d337a] websockect opened: wss://193-118-58-26.edge.agoraio.cn:5889 AgoraRTC_N-production.js:375:113
20:41:46.952 20:41:46:953 Agora-SDK [INFO]: [client-d337a] connection state change: RECONNECTING -> CONNECTED AgoraRTC_N-production.js:375:233
20:41:46.957 20:41:46:957 Agora-SDK [DEBUG]: [client-d337a-pub-1] start reconnect pc AgoraRTC_N-production.js:375:113
20:41:46.971 WebRTC: Using more than two STUN/TURN servers slows down discovery 2 AgoraRTC_N-production.js:705
20:41:46.974 WebRTC: Using five or more STUN/TURN servers causes problems AgoraRTC_N-production.js:705
20:41:47.014 20:41:47:15 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:41:47.099 20:41:47:100 Agora-SDK [DEBUG]: [client-d337a-pub-1] set answer success AgoraRTC_N-production.js:375:113
20:41:47.167 20:41:47:167 Agora-SDK [INFO]: [client-d337a-pub-1] ice-state: pub p2p checking AgoraRTC_N-production.js:375:233
20:41:47.171 20:41:47:171 Agora-SDK [INFO]: [client-d337a-pub-1] connection-state: pub p2p connecting AgoraRTC_N-production.js:375:233
20:41:50.651 20:41:50:650 Agora-SDK [DEBUG]: [pc-2] onicecandidate timeout, local candidate count 16 AgoraRTC_N-production.js:375:113
20:41:51.984 20:41:51:984 Agora-SDK [DEBUG]: [pc-3] onicecandidate timeout, local candidate count 14 AgoraRTC_N-production.js:375:113
20:41:57.246 20:41:57:247 Agora-SDK [DEBUG]: [client-d337a] receive p2p lost 
Object { event: "publish", p2pid: 3, uid: "h2uR9JUyyUcu3YwywmxrhHguRwJ2" }
AgoraRTC_N-production.js:375:113
20:41:57.254 20:41:57:254 Agora-SDK [INFO]: [client-d337a-pub-1] pub p2p gateway lost AgoraRTC_N-production.js:375:233
20:41:57.257 20:41:57:258 Agora-SDK [DEBUG]: [client-d337a-pub-1] start reconnect pc AgoraRTC_N-production.js:375:113
20:41:57.376 WebRTC: Using more than two STUN/TURN servers slows down discovery 2 AgoraRTC_N-production.js:705
20:41:57.378 WebRTC: Using five or more STUN/TURN servers causes problems AgoraRTC_N-production.js:705
20:41:57.420 20:41:57:420 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:41:57.591 20:41:57:591 Agora-SDK [DEBUG]: [client-d337a-pub-1] set answer success AgoraRTC_N-production.js:375:113
20:41:57.621 20:41:57:621 Agora-SDK [INFO]: [client-d337a-pub-1] ice-state: pub p2p checking AgoraRTC_N-production.js:375:233
20:41:57.625 20:41:57:625 Agora-SDK [INFO]: [client-d337a-pub-1] connection-state: pub p2p connecting AgoraRTC_N-production.js:375:233
20:42:02.392 20:42:02:393 Agora-SDK [DEBUG]: [pc-4] onicecandidate timeout, local candidate count 14 AgoraRTC_N-production.js:375:113
20:42:07.706 20:42:07:707 Agora-SDK [DEBUG]: [client-d337a] receive p2p lost 
Object { event: "publish", p2pid: 4, uid: "h2uR9JUyyUcu3YwywmxrhHguRwJ2" }
AgoraRTC_N-production.js:375:113
20:42:07.713 20:42:07:714 Agora-SDK [INFO]: [client-d337a-pub-1] pub p2p gateway lost AgoraRTC_N-production.js:375:233
20:42:07.723 20:42:07:723 Agora-SDK [DEBUG]: [client-d337a-pub-1] start reconnect pc AgoraRTC_N-production.js:375:113
20:42:07.797 WebRTC: Using more than two STUN/TURN servers slows down discovery 2 AgoraRTC_N-production.js:705
20:42:07.801 WebRTC: Using five or more STUN/TURN servers causes problems AgoraRTC_N-production.js:705
20:42:07.838 20:42:07:838 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:42:07.930 20:42:07:931 Agora-SDK [DEBUG]: [gateway-client-d337a] websocket close wss://193-118-58-26.edge.agoraio.cn:5889/, code: 1006, reason: , current mode: retry AgoraRTC_N-production.js:375:113
20:42:07.935 20:42:07:936 Agora-SDK [INFO]: [client-d337a] connection state change: CONNECTED -> RECONNECTING AgoraRTC_N-production.js:375:233
20:42:07.939 20:42:07:939 Agora-SDK [DEBUG]: [client-d337a] ready to reconnect high stream AgoraRTC_N-production.js:375:113
20:42:07.950 rec retry true AgoraRTC_N-production.js:604:396
20:42:07.954 20:42:07:953 Agora-SDK [DEBUG]: [client-d337a] renewSession F2EEDD3DC589682734C25868E718D468 => 67F0BC1942DB323CB4B8CC15BA8E526A AgoraRTC_N-production.js:375:113
20:42:07.960 20:42:07:961 Agora-SDK [DEBUG]: [client-d337a] ready to reconnect high stream AgoraRTC_N-production.js:375:113
20:42:07.967 20:42:07:968 Agora-SDK [DEBUG]: [gateway-client-d337a] wait 500ms to reconnect websocket, mode: tryNext AgoraRTC_N-production.js:375:113
20:42:07.987
20:42:07:987 Agora-SDK [ERROR]: AgoraRTCError WS_ABORT: type: publish AgoraRTC_N-production.js:375:450
20:42:08.475 20:42:08:475 Agora-SDK [DEBUG]: [gateway-client-d337a] websocket url length: 3 current index: 2 AgoraRTC_N-production.js:375:113
20:42:08.479 20:42:08:479 Agora-SDK [DEBUG]: [gateway-client-d337a] start connect, url: wss://193-118-60-54.edge.agora.io:5891 AgoraRTC_N-production.js:375:113
20:42:08.863 20:42:08:863 Agora-SDK [DEBUG]: [gateway-client-d337a] websockect opened: wss://193-118-60-54.edge.agora.io:5891 AgoraRTC_N-production.js:375:113
20:42:08.985 20:42:08:985 Agora-SDK [INFO]: [client-d337a] connection state change: RECONNECTING -> CONNECTED AgoraRTC_N-production.js:375:233
20:42:08.989 20:42:08:989 Agora-SDK [DEBUG]: [client-d337a-pub-1] start reconnect pc AgoraRTC_N-production.js:375:113
20:42:09.005 WebRTC: Using more than two STUN/TURN servers slows down discovery 2 AgoraRTC_N-production.js:705
20:42:09.007 WebRTC: Using five or more STUN/TURN servers causes problems 3 AgoraRTC_N-production.js:705
20:42:09.047 20:42:09:47 Agora-SDK [DEBUG]: [client-d337a-pub-1] create and set offer success AgoraRTC_N-production.js:375:113
20:42:09.214 20:42:09:214 Agora-SDK [DEBUG]: [client-d337a-pub-1] set answer success AgoraRTC_N-production.js:375:113
20:42:09.274 20:42:09:275 Agora-SDK [INFO]: [client-d337a-pub-1] ice-state: pub p2p checking AgoraRTC_N-production.js:375:233
20:42:09.278 20:42:09:278 Agora-SDK [INFO]: [client-d337a-pub-1] connection-state: pub p2p connecting

如您所见,它在发布时失败,Client.publish timeout然后是receive p2p lostand pub p2p gateway lost。然后它不断地重试start reconnect pc

什么可能导致这种行为?

如果我需要提供有关此问题的更多信息,请告诉我。

4

1 回答 1

0

p2p 错误可以通过Agora 错误常见问题解答中提到的不同方式解决。

错误的可能解决方案

如果故障排除后错误仍然存​​在,请联系 support@agora.io。

于 2020-09-22T12:43:46.063 回答