AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://airensoft.com/ome.html
GNU Affero General Public License v3.0
2.58k stars 1.06k forks source link

WebRTC over TCP Firefox Issues #403

Closed ryan77627 closed 3 years ago

ryan77627 commented 3 years ago

Describe the bug I am having issues getting a live stream to play using WebRTC/TCP on Firefox 88. Using my OME instance, Firefox is unable to nominate any ICE Candidates when using the TURN Server. UDP Connects fine but my connection has unacceptable UDP performance, causing packet dropping not seen with a TURN Server in Brave. When I stream to the demo instance running at rtmp://dev2.airensoft.com, Firefox is able to nominate an ICE candidate, but it resets the connection after about 1-2 seconds of slow playback.

To Reproduce Steps to reproduce the behavior:

  1. Using the following Server.xml, start a live stream using stream key teststream1
  2. Try to watch using the following url: wss://stream.stoicproductions.org:37649/live/teststream1?transport=tcp
  3. On chromium based browsers and safari, the WebRTC/TCP stream works perfect. Firefox either fails to establish a connection or drops it immediately.

Server.xml

<Server version="8">
        <Name>StoicEncoder</Name>
        <Type>origin</Type>
        <IP>*</IP>
        <StunServer>stun.l.google.com:19302</StunServer>
        <Bind>
                <Providers>
                        <RTMP>
                                <Port>1935</Port>
                        </RTMP>
                </Providers>
                <Publishers>
                        <HLS>
                                <Port>80</Port>
                        </HLS>
                        <DASH>
                                <Port>80</Port>
                        </DASH>
                        <WebRTC>
                                <Signalling>
                                        <TLSPort>3333</TLSPort>
                                </Signalling>
                                <IceCandidates>
                                        <TcpRelay>68.194.0.82:30000</TcpRelay>
                                        <IceCandidate>68.194.0.82:30001-30005/udp</IceCandidate>
                                </IceCandidates>
                        </WebRTC>
                        <Thumbnail>
                                <Port>80</Port>
                        </Thumbnail>
                </Publishers>
        </Bind>
        <VirtualHosts>
                <VirtualHost>
                        <Name>default</Name>
                        <Host>
                                <Names>
                                        <Name>stream.stoicproductions.org</Name>
                                        <Name>68.194.0.82</Name>
                                        <Name>192.168.1.131</Name>
                                </Names>
                                <TLS>
                                        <CertPath>***REDACTED***</CertPath>
                                        <KeyPath>***REDACTED***</KeyPath>
                                </TLS>
                        </Host>
                        <Applications>
                                <Application>
                                        <Name>live</Name>
                                        <Type>live</Type>
                                        <OutputProfiles>
                                                <OutputProfile>
                                                        <Name>bypass_stream</Name>
                                                        <OutputStreamName>${OriginStreamName}</OutputStreamName>
                                                        <Encodes>
                                                                <Audio>
                                                                        <Bypass>true</Bypass>
                                                                </Audio>
                                                                <Audio>
                                                                        <Codec>opus</Codec>
                                                                        <Bitrate>128000</Bitrate>
                                                                        <Samplerate>48000</Samplerate>
                                                                        <Channel>2</Channel>
                                                                </Audio>
                                                                <Video>
                                                                        <Bypass>true</Bypass>
                                                                </Video>
                                                                <Image>
                                                                        <Codec>jpeg</Codec>
                                                                        <Framerate>1</Framerate>
                                                                        <Width>800</Width>
                                                                        <Height>450</Height>
                                                                </Image>
                                                        </Encodes>
                                                </OutputProfile>
                                        </OutputProfiles>
                                        <Providers>
                                                <RTMP/>
                                        </Providers>
                                        <Publishers>
                                                <StreamLoadBalancingThreadCount>2</StreamLoadBalancingThreadCount>
                                                <HLS>
                                                        <SegmentDuration>3</SegmentDuration>
                                                        <SegmentCount>3</SegmentCount>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                </HLS>
                                                <WebRTC>
                                                        <Timeout>30000</Timeout>
                                                </WebRTC>
                                                <Thumbnail>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                </Thumbnail>
                                                <LLDASH>
                                                        <SegmentDuration>3</SegmentDuration>
                                                        <CrossDomains>
                                                                <Url>*</Url>
                                                        </CrossDomains>
                                                </LLDASH>
                                        </Publishers>
                                </Application>
                        </Applications>
                </VirtualHost>
        </VirtualHosts>
        <P2P>
                <MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
        </P2P>
</Server>

Expected behavior The stream plays properly and doesn't disconnect.

Logs From Right after I start the stream on my instance of OME:

live_server_1  | [2021-06-03 06:39:15.197] W [Dech264:186] FFmpeg | third_parties.cpp:114  | [SWScaler: 0x7f5890041f40] deprecated pixel format used, make sure you did set range correctly
live_server_1  | [2021-06-03 06:39:15.212] I [OutboundWorker:77] WebRTC Publisher | rtc_stream.cpp:177  | Unsupported codec(Video/JPEG) is being input from media track
live_server_1  | [2021-06-03 06:39:15.212] I [OutboundWorker:77] WebRTC Publisher | rtc_stream.cpp:267  | Unsupported codec(Audio/AAC) is being input from media track
live_server_1  | [2021-06-03 06:39:15.213] I [OutboundWorker:77] Publisher | stream.cpp:181  | WebRTC Publisher Application application has started [teststream1(4033996505)] stream
live_server_1  | [2021-06-03 06:39:15.213] I [OutboundWorker:77] Publisher | stream.cpp:181  | HLS Publisher Application application has started [teststream1(4033996505)] stream
live_server_1  | [2021-06-03 06:39:15.213] I [OutboundWorker:77] Publisher | stream.cpp:181  | LLDASH Publisher Application application has started [teststream1(4033996505)] stream
live_server_1  | [2021-06-03 06:39:15.684] W [Rescaler:197] FFmpeg | third_parties.cpp:114  | [SWScaler: 0x7f589c0574c0] deprecated pixel format used, make sure you did set range correctly
live_server_1  | [2021-06-03 06:39:15.686] W [Rescaler:197] FFmpeg | third_parties.cpp:114  | [SWScaler: 0x7f589c0574c0] deprecated pixel format used, make sure you did set range correctly
live_server_1  | [2021-06-03 06:39:15.687] W [Rescaler:197] FFmpeg | third_parties.cpp:114  | [SWScaler: 0x7f589c0574c0] deprecated pixel format used, make sure you did set range correctly
live_server_1  | [2021-06-03 06:39:18.915] I [AppWorker:83] LLDASH | cmaf_packetizer.cpp:766  | [0x7f58a400c870] LLDASH segment is ready to stream [#default#live/teststream1], segment duration: 3.000000s, count: 1
live_server_1  | [2021-06-03 06:39:25.442] I [AppWorker:81] HLS | hls_packetizer.cpp:408  | [#default#live/teststream1] HLS: Segments are ready, segment duration: 3.000000s, count: 3
live_server_1  | [2021-06-03 06:39:31.762] I [SPRtcSignalling:11] Signalling | rtc_signalling_server.cpp:184  | New client is connected: <ClientSocket: 0x7f58b4044d30, #61, Connected, TCP, Nonblocking, 68.194.0.82:1028>
live_server_1  | [2021-06-03 06:39:31.814] I [SPRtcSignalling:11] Monitor | stream_metrics.cpp:119  | A new session has started playing #default#live/teststream1 on the WebRTC publisher. WebRTC(1)/Stream total(1)/App total(1)
live_server_1  | [2021-06-03 06:39:31.814] W [SPRtcSignalling:11] Signalling | rtc_signalling_server.cpp:766  | [Host -> OME] The host peer sents an empty candidate
live_server_1  | [2021-06-03 06:39:34.518] I [SPRtcSignalling:11] WebRTC Publisher | webrtc_publisher.cpp:549  | Stop commnad received : #default#live/teststream1/136
live_server_1  | [2021-06-03 06:39:34.519] I [SPRtcSignalling:11] Monitor | stream_metrics.cpp:144  | A session has been stopped playing #default#live/teststream1 on the WebRTC publisher. Concurrent Viewers[WebRTC(0)/Stream total(0)/App total(0)]
live_server_1  | [2021-06-03 06:39:34.519] I [SPRtcSignalling:11] Signalling | rtc_signalling_server.cpp:322  | Client is disconnected: <WebSocketClient: 0x7f586c085980, <ClientSocket: 0x7f58b4044d30, #61, Closed, TCP, Nonblocking, 68.194.0.82:1028>> (#default#live / teststream1, ufrag: local: VLxymE, remote: 51cdff4f)

When I view with chrome, I do not see the "The host peer sents an empty candidate", other than that the connection log is identical.

Server (please complete the following information):

Player (please complete the following information):

Additional context I will run my instance of OME if it may help with debugging any issues my server or the Encoder may have with firefox. If it crashes, please let me know as my streaming computer is not stable at the moment. I'm going to do more testing at another location tomorrow, maybe it's something with my network.

You can access the stream at wss://stream.stoicproductions.org:37649/live/teststream1?transport=tcp or you can use the link to the player I've been using to test: Player Link. I've included the UDP source as well to verify that the stream does work without the TURN Server.

getroot commented 3 years ago

Thanks for reporting the problem. I'll look into this soon.

ryan77627 commented 3 years ago

Thanks. If you need me to put the stream back up let me know, I have to give my computer a break

getroot commented 3 years ago

I found that stun in firefox behaves differently than other browsers, and I fixed it. Now in my environment both udp and tcp work fine in firefox. Please check if your problem is also solved.

ryan77627 commented 3 years ago

Sure, is this fixed pushed to the example server at dev2.airensoft.com or do I need to build the program?

getroot commented 3 years ago

Please test by building from the master branch. It has not been updated for dev2.

ryan77627 commented 3 years ago

Hey, just got home to build it and pushed to my server to test. So far, it seems to be working correctly on Firefox now! Thanks for your help with the issue.