shinyoshiaki / werift-webrtc

WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP/SRTP/WEBM/MP4
MIT License
488 stars 32 forks source link

onicecandidate: different behaviour than in browser. #402

Open 0wwafa opened 2 months ago

0wwafa commented 2 months ago

In a browser:

                peerConnection.onicecandidate = (event) => {
                    if (event.candidate) {
                        // nothing.. just testing
                    } else {
                        appendMessage('ICE gathering complete');
                        console.log(peerConnection.localDescription.sdp)
                    }
                };

The above code, works in browser. and if an event does not contain a candidate, it means that all the candidates have been gathered. At the same time the sdp contains a full offer. Like:

{"type":"offer","sdp":"v=0
o=- 5710643758777751668 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS
m=application 62604 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 xx.xx.xx.xx
a=candidate:42502408 1 udp 33563135 xx.xx.xx.xx 62604 typ relay raddr yy.yy.yy.yy rport 3955 generation 0 network-cost 999
a=candidate:2085055376 1 udp 16785663 xx.xx.xx.xx 57960 typ relay raddr yy.yy.yy.yy rport 3323 generation 0 network-cost 999
a=candidate:2085055376 1 udp 16785663 xx.xx.xx.xx 62061 typ relay raddr yy.yy.yy.yy rport 3324 generation 0 network-cost 999
a=candidate:2684070260 1 udp 8191 xx.xx.xx.xx 65009 typ relay raddr yy.yy.yy.yy rport 3322 generation 0 network-cost 999
a=candidate:2684070260 1 udp 8191 xx.xx.xx.xx 57122 typ relay raddr yy.yy.yy.yy rport 3957 generation 0 network-cost 999
a=ice-ufrag:hVpz
a=ice-pwd:V9oH1m+M7NxaAHQvL4kKWU6C
a=ice-options:trickle
a=fingerprint:sha-256 38:F4:95:10:B6:A0:0E:99:DB:AE:E1:73:24:32:3E:68:E2:D1:EA:C5:44:24:DF:60:30:1F:13:BF:87:89:E9:08
a=setup:actpass
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
"}

In werift I see 2 problems:

1) the "else" in the above code, never happens. 2) even if I manually wait the end of the ice gathering, the sdp always shows:

v=0
o=- 72372628 0 IN IP4 0.0.0.0
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic:WMS *
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:4bf5
a=ice-pwd:a20cadef8b50715c433442
a=ice-options:trickle
a=fingerprint:sha-256 2F:5B:E1:C7:18:DE:A1:28:F6:F3:71:D0:AA:91:90:5E:D8:BC:B1:32:3F:59:FC:A9:AC:2F:4E:A3:0A:C8:CC:98
a=setup:actpass
a=mid:0
a=sctp-port:5000
a=max-message-size:65536

which means that the candidates are not there and "will be passed later". but that's not what happens in browsers.

shinyoshiaki commented 2 months ago

v0.20.0 to match browser behavior.