sipsorcery
sipsorcery copied to clipboard
External IP in SDP?
What is required to get actual external (not local network/localhost) IP address SDP.
When I get a request where I create a WebRTCPeerConnection I can't seem to get any ip address than localhost. Example SDP: From "createAnswer"
v=0
o=- 79801 0 IN IP4 127.0.0.1
s=sipsorcery
t=0 0
a=group:BUNDLE 0
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=ice-ufrag:ZKIN
a=ice-pwd:WRJWERTWUBZUUXGEDJWLFRGG
a=fingerprint:sha-256 FC:E8:00:90:4A:E0:D5:3E:49:FB:40:2A:D8:18:A7:5E:0A:32:C1:25:D2:0E:77:11:DB:4C:DC:FC:08:AD:70:54
a=setup:actpass
a=candidate:2062 1 udp 2113937663 192.168.1.190 62601 typ host generation 0
a=ice-options:ice2,trickle
a=mid:0
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 packetization-mode=1
a=rtcp-mux
a=rtcp:9 IN IP4 0.0.0.0
a=sendonly
a=ssrc:256302258 cname:3edaa65b-cee7-47aa-adcb-019e1f53433f
I create a RTCPeerConnection with RTCConfiguration of 1 ice Sserver"stun:stun.sipsorcery.com" and also tried google stun .
Using Caddy as reverse proxy
Sipsorcery implement trickle ice connection.
The "External IPs" obtained by STUN/TURN servers will be returned assynchronous at event onIceCandidate and you need to submit it to other user by a signalling server.
If you want to have all candidates into SDP you need to wait rtcpeerconnection.IceGathering != New as Ice-Servers take some time to discover your External IP (and thats why trickle ice exists)
In order to test this I am running the example WebRTCTestPatternServer . I changed it so it uses STUN server
private const string STUN_URL = "stun:stun.l.google.com:19302";
On connection the log is:
[10:18:57 DBG] Web socket client connection from 194.237.228.130:52394.
[10:18:57 WRN] No DTLS certificate is provided in the configuration
[10:18:59 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0.
[10:18:59 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:0 using protocol Udp.
[10:18:59 DBG] CreateBoundSocket successfully bound on [::]:64553, dual mode True.
[10:18:59 DBG] Successfully bound RTP socket [::]:64553 (dual mode True).
[10:18:59 DBG] RTPChannel for [::]:64553 started.
[10:18:59 DBG] SCTP windows size for data receiver set at 218.
[10:18:59 DBG] SCTP creating DTLS based association, is DTLS client False, ID 5000:5000:64553.
[10:18:59 DBG] Adding ICE server for stun:stun.l.google.com:19302.
[10:18:59 INF] FFmpeg version info: 4.4.1-full_build-www.gyan.dev
[10:18:59 DBG] RTP ICE Channel discovered 1 local candidates.
[10:18:59 DBG] Adding ICE server for stun:stun.l.google.com:19302.
[10:18:59 DBG] Attempting to resolve STUN server URI stun:stun.l.google.com:19302.
[10:18:59 DBG] Local SDP set, type offer.
[10:18:59 DBG] ICE server stun:stun.l.google.com:19302 successfully resolved to 108.177.14.127:19302.
[10:18:59 DBG] v=0
o=- 43519 0 IN IP4 127.0.0.1
s=sipsorcery
t=0 0
a=group:BUNDLE 0
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=ice-ufrag:NFQS
a=ice-pwd:GPQNCOWFGXCSRITHAWBNEGXW
a=fingerprint:sha-256 97:60:B8:66:E1:91:3C:58:05:8A:73:C2:D7:1F:46:9D:D9:EE:4A:17:21:63:F3:9E:04:D6:C1:85:9F:4A:6A:A0
a=setup:actpass
a=candidate:3898879193 1 udp 2113937663 192.168.1.190 64553 typ host generation 0
a=mid:0
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 packetization-mode=1
a=ice-options:ice2,trickle
a=rtcp-mux
a=rtcp:9 IN IP4 0.0.0.0
a=sendonly
a=ssrc:913312124 cname:f495617f-e940-4f88-8e78-1e23f0c73016
[10:18:59 DBG] Sending SDP offer to client 194.237.228.130:52394.
[10:18:59 DBG] v=0
o=- 43519 0 IN IP4 127.0.0.1
s=sipsorcery
t=0 0
a=group:BUNDLE 0
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=ice-ufrag:NFQS
a=ice-pwd:GPQNCOWFGXCSRITHAWBNEGXW
a=fingerprint:sha-256 97:60:B8:66:E1:91:3C:58:05:8A:73:C2:D7:1F:46:9D:D9:EE:4A:17:21:63:F3:9E:04:D6:C1:85:9F:4A:6A:A0
a=setup:actpass
a=candidate:3898879193 1 udp 2113937663 192.168.1.190 64553 typ host generation 0
a=ice-options:ice2,trickle
a=mid:0
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 packetization-mode=1
a=rtcp-mux
a=rtcp:9 IN IP4 0.0.0.0
a=sendonly
a=ssrc:913312124 cname:f495617f-e940-4f88-8e78-1e23f0c73016
[10:18:59 DBG] Got remote SDP, type answer.
[10:18:59 DBG] RTP ICE Channel remote credentials set.
[10:18:59 DBG] ICE connection state change to checking.
[10:18:59 DBG] SDP:[v=0
o=- 588112252143071325 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=ice-ufrag:eg6p
a=ice-pwd:tm1CJ9uHJ10qSWLdZUBAYLAE
a=fingerprint:sha-256 76:42:13:4D:94:DB:56:D4:F8:77:61:DD:D3:6D:DB:88:01:41:54:7F:19:04:E6:E1:28:A0:3A:2A:B2:AE:01:46
a=setup:active
a=mid:0
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtcp:9 IN IP4 0.0.0.0
a=ice-options:trickle
a=rtcp-mux
a=recvonly
]
[10:18:59 DBG] LogRemoteSDPSsrcAttributes: Audio:[ ]
Video: [ [] ]
[10:18:59 DBG] Got remote ICE candidate.
[10:18:59 DBG] Sending STUN binding request to ICE server stun:stun.l.google.com:19302 with address 108.177.14.127:19302.
[10:18:59 DBG] STUN binding success response received for ICE server check to stun:stun.l.google.com:19302.
[10:18:59 DBG] Adding server reflex ICE candidate for ICE server stun:stun.l.google.com:19302 and 213.102.85.145:64553.
[10:18:59 DBG] ICE RTP channel stopping ICE server checks in gathering state complete and connection state checking.
[10:19:15 WRN] ICE RTP channel failed to connect as no checklist entries became available within 16,03s.
[10:19:15 DBG] ICE connection state change to failed.
[10:19:15 DBG] Peer connection state change to failed.
[10:19:15 DBG] Peer connection closed with reason ice disconnection.
[10:19:15 DBG] RtpIceChannel for [::]:64553 closed.
[10:19:15 DBG] RTPChannel closing, RTP receiver on port 64553. Reason: ice disconnection.
[10:19:15 DBG] Peer connection state change to closed.
[10:19:16 DBG] VideoEncoder dispose.
On the client (webrtc.html)
OnMessage on websocket I get this:
{"type":"offer","sdp":"v=0\r\no=- 93241 0 IN IP4 127.0.0.1\r\ns=sipsorcery\r\nt=0 0\r\na=group:BUNDLE 0\r\nm=video 9 UDP/TLS/RTP/SAVP 96 100\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:OVBD\r\na=ice-pwd:DINNIIJUPYMZNOUBHJKFJOQD\r\na=fingerprint:sha-256 D0:F3:A7:96:44:DC:92:9E:A6:DC:B0:3F:78:0F:9D:00:07:5C:C4:09:C0:8C:7A:F8:F5:D9:1E:0A:29:41:A0:60\r\na=setup:actpass\r\na=candidate:3898879193 1 udp 2113937663 192.168.1.190 54158 typ host generation 0\r\na=ice-options:ice2,trickle\r\na=mid:0\r\na=rtpmap:96 VP8/90000\r\na=rtpmap:100 H264/90000\r\na=fmtp:100 packetization-mode=1\r\na=rtcp-mux\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=sendonly\r\na=ssrc:959812347 cname:fe4bb365-5a1a-492e-a80e-5b4e34dc0362\r\n"}
And then
AddIceCandidate gets:
{"candidate":"candidate:136748507 1 udp 1677730047 213.102.85.145 64553 typ srflx raddr 0.0.0.0 rport 0 generation 0","sdpMid":"0","sdpMLineIndex":0,"usernameFragment":"NFQS"}
Do you happen to know what could be wrong? Is there a firewall issue?
I think I have misunderstood how SDP ansers and new ice-candidates work. I based my code around the WebRTCTestPatternRest . That example seem to only send an answer which will always only include local ip.
I need to continiously add ice-candidates as they become available. Hopefulle resolved soon