node-webrtc / node-webrtc-examples

MediaStream and RTCDataChannel examples using node-webrtc
508 stars 161 forks source link

Unable to record video from different network #37

Open co2nut opened 3 years ago

co2nut commented 3 years ago

Based on examples/record-audio-video-stream, when I run it on different network, it seems that it does not go through this listener

videoSink.addEventListener('frame', ({ frame: { width, height, data }}) => {

everything works fine on same network.

I tried to add below config too, but no luck

peerConnections = new RTCPeerConnection({
            sdpSemantics: 'unified-plan',
            iceServers: [
              {
                urls : 'stun:stun.l.google.com:19302'
              },
              {
                urls : 'turn:numb.viagenie.ca',
                username: "abc@hotmail.com",
                credential: "password",
              }
            ]
          }    
})

Is there anything that I could possibly miss out?

Pirsanth commented 3 years ago

I am facing this same issue. Is there a way to resolve this?

kalradivyanshu commented 3 years ago

Same issue

TurningTide commented 3 years ago

Same issue

brndusic commented 3 years ago

Has anyone solved this?

milochen0418 commented 3 years ago

Refer the document here. These examples are not currently support for srflx/relay candidate. So STUN/TURN server cannot work for these example right now.
https://github.com/node-webrtc/node-webrtc-examples/blob/master/README.md


RTCPeerConnection Negotiation

RTCPeerConnections are negotiated via REST API. The Server always offers (with host candidates) and the Client always answers. In order to negotiate a new RTCPeerConnection, the Client first POSTs to /connections. The Server responds with an RTCPeerConnection ID and SDP offer. Finally, the Client POSTs an SDP answer to the RTCPeerConnection's URL.

Client                                               Server
  |                                                     |
  |  POST /connections                                  |
  |                                                     |
  |---------------------------------------------------->|
  |                                                     |
  |                                             200 OK  |
  |  { "id": "$ID", "localDescription": "$SDP_OFFER" }  |
  |                                                     |
  |<----------------------------------------------------|
  |                                                     |
  |  POST /connections/$ID/remote-description           |
  |  $SDP_ANSWER                                        |
  |                                                     |
  |---------------------------------------------------->|
  |                                                     |
  |                                             200 OK  |
  |                                                     |
  |<----------------------------------------------------|