microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
898 stars 277 forks source link

Help required: Crash on getting offer. #850

Open maskrtnik01 opened 2 years ago

maskrtnik01 commented 2 years ago

Hello,

I would like to ask you for a help. I am developing WebRTC server/client app pair for streaming Kinect sensor readings. Channeling using WebSocketSharp library.

At the beginning server sends this offer (for some reason I do not see it coming to client) v=0 o=- 2846874343951573710 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/SAVPF 96 97 98 99 100 101 127 124 125 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 a=ice-ufrag:eRDX a=ice-pwd:T3Aj3D7rlUgDcOBkLDosyYmA a=ice-options:trickle a=fingerprint:sha-256 72:3F:7D:46:51:DB:E2:B0:6D:D0:48:B4:9E:7B:FB:0F:37:A1:7A:E6:32:CD:C3:FF:C1:3A:FD:51:E1:9D:9C:A4 a=setup:actpass a=mid:0 a=extmap:2 urn:ietf:params:rtp-hdrext:toffset a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:4 urn:3gpp:video-orientation a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing a=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07 a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid a=sendrecv a=msid:- c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=rtcp-mux a=rtcp-rsize a=rtpmap:96 VP8/90000 a=rtcp-fb:96 goog-remb a=rtcp-fb:96 transport-cc a=rtcp-fb:96 ccm fir a=rtcp-fb:96 nack a=rtcp-fb:96 nack pli a=rtpmap:97 rtx/90000 a=fmtp:97 apt=96 a=rtpmap:98 VP9/90000 a=rtcp-fb:98 goog-remb a=rtcp-fb:98 transport-cc a=rtcp-fb:98 ccm fir a=rtcp-fb:98 nack a=rtcp-fb:98 nack pli a=fmtp:98 x-google-profile-id=0 a=rtpmap:99 rtx/90000 a=fmtp:99 apt=98 a=rtpmap:100 multiplex/90000 a=rtcp-fb:100 goog-remb a=rtcp-fb:100 transport-cc a=rtcp-fb:100 ccm fir a=rtcp-fb:100 nack a=rtcp-fb:100 nack pli a=fmtp:100 acn=VP9;x-google-profile-id=0 a=rtpmap:101 rtx/90000 a=fmtp:101 apt=100 a=rtpmap:127 red/90000 a=rtpmap:124 rtx/90000 a=fmtp:124 apt=127 a=rtpmap:125 ulpfec/90000 a=ssrc-group:FID 3837032499 1540272127 a=ssrc:3837032499 cname:XCyqXhTeNXKeeYLi a=ssrc:3837032499 msid: c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:3837032499 mslabel: a=ssrc:3837032499 label:c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:1540272127 cname:XCyqXhTeNXKeeYLi a=ssrc:1540272127 msid: c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:1540272127 mslabel: a=ssrc:1540272127 label:c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9

Server sends this ICE candidate candidate:3013953624 1 udp 2122260223 192.168.1.100 49548 typ host generation 0 ufrag eRDX network-id 1

At this time server sends this offer. When client receives it, client crashes with exception "Value does not fall within expected range." v=0 o=- 2846874343951573710 3 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE 0 a=msid-semantic: WMS m=video 49548 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127 124 125 c=IN IP4 192.168.1.100 a=rtcp:9 IN IP4 0.0.0.0 a=candidate:3013953624 1 udp 2122260223 192.168.1.100 49548 typ host generation 0 network-id 1 a=ice-ufrag:eRDX a=ice-pwd:T3Aj3D7rlUgDcOBkLDosyYmA a=ice-options:trickle a=fingerprint:sha-256 72:3F:7D:46:51:DB:E2:B0:6D:D0:48:B4:9E:7B:FB:0F:37:A1:7A:E6:32:CD:C3:FF:C1:3A:FD:51:E1:9D:9C:A4 a=setup:actpass a=mid:0 a=extmap:2 urn:ietf:params:rtp-hdrext:toffset a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:4 urn:3gpp:video-orientation a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing a=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07 a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid a=sendonly a=msid:- c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=rtcp-mux a=rtcp-rsize a=rtpmap:96 VP8/90000 a=rtcp-fb:96 goog-remb a=rtcp-fb:96 transport-cc a=rtcp-fb:96 ccm fir a=rtcp-fb:96 nack a=rtcp-fb:96 nack pli a=rtpmap:97 rtx/90000 a=fmtp:97 apt=96 a=rtpmap:98 VP9/90000 a=rtcp-fb:98 goog-remb a=rtcp-fb:98 transport-cc a=rtcp-fb:98 ccm fir a=rtcp-fb:98 nack a=rtcp-fb:98 nack pli a=fmtp:98 x-google-profile-id=0 a=rtpmap:99 rtx/90000 a=fmtp:99 apt=98 a=rtpmap:100 multiplex/90000 a=rtcp-fb:100 goog-remb a=rtcp-fb:100 transport-cc a=rtcp-fb:100 ccm fir a=rtcp-fb:100 nack a=rtcp-fb:100 nack pli a=fmtp:100 acn=VP9;x-google-profile-id=0 a=rtpmap:101 rtx/90000 a=fmtp:101 apt=100 a=rtpmap:127 red/90000 a=rtpmap:124 rtx/90000 a=fmtp:124 apt=127 a=rtpmap:125 ulpfec/90000 a=ssrc-group:FID 3837032499 1540272127 a=ssrc:3837032499 cname:XCyqXhTeNXKeeYLi a=ssrc:3837032499 msid: c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:3837032499 mslabel: a=ssrc:3837032499 label:c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:1540272127 cname:XCyqXhTeNXKeeYLi a=ssrc:1540272127 msid: c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9 a=ssrc:1540272127 mslabel: a=ssrc:1540272127 label:c1c0b92a-b8c6-4fb9-a34f-d41db8c5c9f9

Server also sends this ICE candidate(IP address removed), however by the time client could receive it, it is already crashed. candidate:854413036 1 udp 1686052607 *.*.*.* 49548 typ srflx raddr 192.168.1.100 rport 49548 generation 0 ufrag eRDX network-id 1

Does anyone see what is wrong with my setup? Both client and server are running on a single Windows 11 machine, Visual Studio Community 2022, .NET FW 4.8

Nuget packages: Microsoft.MixedReality.WebRTC 2.0.2 mrwebrtc 2.0.2 (here I had to manually copy DLLs to project build folder) WebSocketSharp-netstandard 1.0.1 (server only) Microsoft.Kinect 2.0.1410.19000

Thanks in advance, Stanislav

maskrtnik01 commented 2 years ago

I found it, quite dumb thing. I would like to recommend you to make exception messages more specific - it could have saved me a lot of time.

Now to explain what happened, this is code to send SDPs via WebSocket: private void WebRTC_LocalSdpReadytoSend(SdpMessage message) { using (StringWriter wr = new StringWriter()) { switch (message.Type) { case SdpMessageType.Offer: wr.WriteLine("SDPOffer"); wr.Write(message.Content); break; case SdpMessageType.Answer: wr.WriteLine("SDPAnswer"); wr.Write(message.Content); break; } DebugUtils.LogSdpMessageTx(message); WebSocket.Send(wr.ToString()); } }

I had wr.WriteLine(message.Content) , this way I got empty line at the end of each SDP message. I was getting a very ambiguous exception. Changed to above code, problem solved.

Stanislav