AirenSoft / OvenMediaEngine

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

Infinite loading / Can't grab the stream #282

Closed sephentos closed 3 years ago

sephentos commented 3 years ago

Describe the bug Opening ws://192.168.114.193:3333/app/stream in the OME demo player results in infinite loading

grafik

OME log when clicking 'load source' on the demo player:

[2021-02-13 04:57:00.739] I [PhyPortWorker:184] Signalling | rtc_signalling_server.cpp:129  | New client is connected:<ClientSocket: 0x7f9268000b90, #39, state: 4, TCP, 192.168.115.232:4268>
[2021-02-13 04:57:01.513] I [PhyPortWorker:184] Monitor | stream_metrics.cpp:119  | A new session has started playing #default#app/stream on the WebRTC publisher. WebRTC(1)/Stream total(1)/App total(1)

I'm using OBS to stream with the recommended settings given here

grafik grafik

The logs are fine when starting streaming, OBS is streaming successfully without any loss of fragments. I just can't manage to grab the source in VLC or the demo player (while in VLC every possible source I've tried always directly failed)

Server:

Additional context Opening http://192.168.114.193:8080/app/stream/playlist.m3u8 in VLC does not even produce a log and VLC directly quits telling the source could not be found. Same for http://192.168.114.193:8080/app/stream/manifest.mpd

Although all ports are allowed i've disabled ufw while not on production.

(The IP is private, yes. Streaming with NGINX+RTMP or Project-Lightspeed were working. So there shouldn't be a problem with routing / NAT)

Server.Xml is untouched - everything is default; Non-docker setup, installation was made with these instructions.

getroot commented 3 years ago

Try setting the B-frames to 0. The browser's WebRTC does not support b-frames.

getroot commented 3 years ago

Is the HLS port in Server.xml set to 8080? The default port for the installed version of Server.xml, not the Docker version, is port 80. Check out Server.xml.

dbContext commented 3 years ago

Could you please clarify whether you're attempting to load the video player via demo.ovenplayer.com?

If you are, that is the problem. You're attempting to load 192.168.114.193, which is inside a private LAN range, not public facing.

So you're never going to establish a connection via a WAN / public facing website to your LAN.

You'll either need to open the relevant ports for establishing web sockets, HTTP and WebRTC to allow WAN->LAN or host the environment within a public infrastructure (Vultr / DigitalOcean / Azure / AWS / Google Cloud etc)

sephentos commented 3 years ago

UPDATE: see next comment

@getroot Changed B-frames to 0 and yeah HLS was 8080.

@dbContext

I've changed my env. a little bit, it is now a public accessible domain + IP. All required ports are open.

I've also set up SSL for wss:// and I've set up everything in Server.xml for it.

But now I am getting this error in chromes console:

Connection with low-latency(OME) server failed

code: 501
​
error: error { target: WebSocket, isTrusted: true, srcElement: WebSocket, … }
​
message: "Connection with low-latency(OME) server failed."
​
reason: "WebSocket connection failed."
​
<prototype>: {…

when trying to fetch wss://domain:3334/app/stream via https://demo.ovenplayer.com/ It also fails with the OME media player placed on the site behind the domain.

Also nothing special is being logged while trying to fetch the stream. There are just some random ICE logs:

[2021-02-18 18:57:09.357] E [PhyPortDgSock:11610] Ice | ice_port.cpp:596  | Could not parse STUN packet from <DatagramSocket: 0x562ce544e270, #11, state: 2, UDP, N/A>

(they also come when I do not try to fetch the stream)

Here is my Server.xml

<?xml version="1.0" encoding="UTF-8" ?>

<Server version="8">
    <Name>OvenMediaEngine</Name>
    <!-- Host type (origin/edge) -->
    <Type>origin</Type>
    <!-- Specify IP address to bind (* means all IPs) -->
    <IP>*</IP>

    <!-- Settings for the ports to bind -->
    <Bind>
        <!-- Enable this configuration if you want to use API Server -->
        <!--
        <Managers>
            <API>
                <Port>48081</Port>
            </API>
        </Managers>
        -->

        <Providers>
            <RTMP>
                <Port>1935</Port>
            </RTMP>
            <MPEGTS>
                <!--
                    Listen on port 4000~4005
                    This is just a demonstration to show that you can configure the port in several ways
                -->
                <Port>4000-4004,4005/udp</Port>
            </MPEGTS>
        </Providers>

        <Publishers>
            <OVT>
                <Port>9000</Port>
            </OVT>
            <HLS>
                <Port>8080</Port>
                <!-- If you want to use TLS, specify the TLS port -->
                <!-- <TLSPort>443</TLSPort> -->
            </HLS>
            <DASH>
                <Port>8081</Port>
                <!-- If you want to use TLS, specify the TLS port -->
                <!-- <TLSPort>443</TLSPort> -->
            </DASH>
            <WebRTC>
                <Signalling>
                    <Port>3333</Port>
                    <!-- If you want to use TLS, specify the TLS port -->
                     <TLSPort>3334</TLSPort>
                </Signalling>
                <IceCandidates>
                    <TcpRelay>*:3478</TcpRelay>
                    <IceCandidate>*:10000-10005/udp</IceCandidate>
                </IceCandidates>
            </WebRTC>
        </Publishers>
    </Bind>

    <!-- P2P works only in WebRTC -->
    <!--
    <P2P>
        <MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
    </P2P>
    -->

    <!--
        Enable this configuration if you want to use API Server

        <AccessToken> is a token for authentication, and when you invoke the API, you must put "Basic base64encode(<AccessToken>)" in the "Authorization" header of HTTP request.
        For example, if you set <AccessToken> to "ome-access-token", you must set "Basic b21lLWFjY2Vzcy10b2tlbg==" in the "Authorization" header.
    -->
    <!--
    <Managers>
        <Host>
            <Names>
                <Name>*</Name>
            </Names>
            <TLS>
                <CertPath>path/to/file.crt</CertPath>
                <KeyPath>path/to/file.key</KeyPath>
                <ChainCertPath>path/to/file.crt</ChainCertPath>
            </TLS>
        </Host>
        <API>
            <AccessToken>ome-access-token</AccessToken>
        </API>
    </Managers>
    -->

    <VirtualHosts>
        <!-- You can use wildcard like this to include multiple XMLs -->
        <VirtualHost include="VHost*.xml" />
        <VirtualHost>
            <Name>default</Name>

            <!-- Settings for multi ip/domain and TLS -->
            <Host>
                <Names>
                    <!-- Host names
                        <Name>stream1.airensoft.com</Name>
                        <Name>stream2.airensoft.com</Name>
                        <Name>*.sub.airensoft.com</Name>
                        <Name>192.168.0.1</Name>
                    -->
                    <Name>*</Name>
                </Names>

                <TLS>
                    <CertPath>/etc/ssl/certs/domain.crt</CertPath>
                    <KeyPath>/etc/ssl/certs/domain.key</KeyPath>
                </TLS>

            </Host>

            <!-- Refer https://airensoft.gitbook.io/ovenmediaengine/signedpolicy

            <SignedPolicy>
                <PolicyQueryKeyName>policy</PolicyQueryKeyName>
                <SignatureQueryKeyName>signature</SignatureQueryKeyName>
                <SecretKey>aKq#1kj</SecretKey>

                <Enables>
                    <Providers>rtmp</Providers>
                    <Publishers>webrtc,hls,dash,lldash</Publishers>
                </Enables>
            </SignedPolicy>
            -->

            <!--
            <Origins>

                <Origin>
                    <Location>/app/stream</Location>
                    <Pass>
                        <Scheme>ovt</Scheme>
                        <Urls><Url>origin.com:9000/app/stream_720p</Url></Urls>
                    </Pass>
                </Origin>
                <Origin>
                    <Location>/app/</Location>
                    <Pass>
                        <Scheme>ovt</Scheme>
                        <Urls><Url>origin.com:9000/app/</Url></Urls>
                    </Pass>
                </Origin>
                <Origin>
                    <Location>/edge/</Location>
                    <Pass>
                        <Scheme>ovt</Scheme>
                        <Urls><Url>origin.com:9000/app/</Url></Urls>
                    </Pass>
                </Origin>
            </Origins>
            -->
            <!-- Settings for applications -->
            <Applications>
                <Application>
                    <Name>app</Name>
                    <!-- Application type (live/vod) -->
                    <Type>live</Type>
<!--
                    <OutputProfiles>
                        <OutputProfile>
                            <Name>bypass_stream</Name>
                            <OutputStreamName>${OriginStreamName}</OutputStreamName>
                            <Encodes>
                                <Audio>
                                    <Bypass>true</Bypass>
                                </Audio>
                                <Video>
                                    <Bypass>true</Bypass>
                                </Video>
                                <Audio>
                                    <Codec>opus</Codec>
                                    <Bitrate>128000</Bitrate>
                                    <Samplerate>48000</Samplerate>
                                    <Channel>2</Channel>
                                </Audio>
-->
                                <!--                            
                                <Video>
                                    <Codec>vp8</Codec>
                                    <Bitrate>1024000</Bitrate>
                                    <Framerate>30</Framerate>
                                    <Width>1280</Width>
                                    <Height>720</Height>
                                </Video>                                
                                -->
<!--
                            </Encodes>
                        </OutputProfile>
                    </OutputProfiles>
-->
<OutputProfiles>
    <OutputProfile>
        <Name>bypass_stream</Name>
        <OutputStreamName>${OriginStreamName}</OutputStreamName>
        <Encodes>
            <Audio>
                <Bypass>true</Bypass>
            </Audio>
            <Video>
                <Bypass>true</Bypass>
            </Video>
            <Video>
                <Codec>vp8</Codec>
                <Width>1280</Width>
                <Height>720</Height>
                <Bitrate>2000000</Bitrate>
                <Framerate>30.0</Framerate>
            </Video>
            <Audio>
                <Codec>opus</Codec>
                <Bitrate>128000</Bitrate>
                <Samplerate>48000</Samplerate>
                <Channel>2</Channel>
            </Audio>
        </Encodes>
    </OutputProfile>
</OutputProfiles>

                    <Providers>
                        <OVT />
                        <RTMP />
                        <MPEGTS>
                            <StreamMap>
                                <!--
                                    Set the stream name of the client connected to the port to "stream_${Port}"
                                    For example, if a client connets to port 4000, OME creates a "stream_4000" stream
                                -->
                                <Stream>
                                    <Name>stream_${Port}</Name>
                                    <Port>4000,4001-4004</Port>
                                </Stream>
                                <Stream>
                                    <Name>stream_4005</Name>
                                    <Port>4005</Port>
                                </Stream>
                            </StreamMap>
                        </MPEGTS>
                        <RTSPPull />
                    </Providers>
                    <Publishers>
                        <SessionLoadBalancingThreadCount>8</SessionLoadBalancingThreadCount>
                        <OVT />
                        <WebRTC>
                            <Timeout>30000</Timeout>
                        </WebRTC>
                        <HLS>
                            <SegmentDuration>5</SegmentDuration>
                            <SegmentCount>3</SegmentCount>
                            <CrossDomains>
                                <Url>*</Url>
                                <Url>https://demo.ovenplayer.com</Url>
                            </CrossDomains>
                        </HLS>
                        <DASH>
                            <SegmentDuration>5</SegmentDuration>
                            <SegmentCount>3</SegmentCount>
                            <CrossDomains>
                                <Url>*</Url>
                                <Url>https://demo.ovenplayer.com</Url>
                            </CrossDomains>
                        </DASH>
                        <LLDASH>
                            <SegmentDuration>5</SegmentDuration>
                            <CrossDomains>
                                <Url>*</Url>
                                <Url>https://demo.ovenplayer.com</Url>
                            </CrossDomains>
                        </LLDASH>
                    </Publishers>
                </Application>
            </Applications>
        </VirtualHost>
    </VirtualHosts>
</Server>

Note that I only try to fetch WebRTC, so no TLS configurations are made to HLS, etc.

I also thought trying to stream without OBS and using this could solve the issues (which did not unfortunately):

ffmpeg -re -stream_loop -1 -i test.mp4 -vcodec libx264 -preset ultrafast -threads 6 -b:v 1500k -acodec aac -b:a 256k -ar 96000 -f flv rtmp://127.0.0.1:1935/app/stream

sephentos commented 3 years ago

grafik

By some reason after hitting the play button for some times it seems to "work", at least the connection, but the image and audio somehow is destroyed. Also image+audio only updates after some seconds. There is no bandwidth or CPU/RAM issue anywhere. Any idea with that?

grafik grafik

grafik

I still get many ICE / STUN issues in the logs. Accessing via wss://domain:3334/app/stream

In firefox it still fails:

Object { code: 501, message: "Connection with low-latency(OME) server failed.", reason: "WebSocket connection failed.", error: error}

Streamed with:

ffmpeg -re -stream_loop -1 -i test.mp4 -vcodec libx264 -preset ultrafast -threads 6 -b:v 1500k -acodec aac -b:a 256k -ar 96000 -f flv rtmp://127.0.0.1:1935/app/stream (OBS (with bframes 0) results to the same)

getroot commented 3 years ago

@sephentos

There have been several patches related to stun recently, so please update the latest master. And please upload the entire ovenmediaengine.log.

And when using TLS, it is recommended to write the domain in host name instead of *.

* Issues related to video quality may be related to high packet loss or MTU. Refer to #282 and test with WebRTC/TCP (transport=tcp) or lower the mtu of the system to 1400.
sephentos commented 3 years ago

@getroot

There have been several patches related to stun recently, so please update the latest master. And please upload the entire ovenmediaengine.log.

I already noticed these patches and already have been using the latest patches from master and have rebuild the server.

And when using TLS, it is recommended to write the domain in host name instead of .

I am not really sure which place to write you mean with that. Mind checking my Server.xml?

https://pastebin.com/7hPjViAi

Issues related to video quality may be related to high packet loss or MTU.

Changed MTU to 1400.

Now it is not even starting to play. Still getting my first issue again:

{code: 501, message: "Connection with low-latency(OME) server failed.", reason: "WebSocket connection failed.", error: Event}

Here is my complete OME log:

https://pastebin.com/FLZqTMh9

Streaming via:

ffmpeg -re -stream_loop -1 -i test.mp4 -vcodec libx264 -preset ultrafast -threads 6 -b:v 1500k -acodec aac -b:a 256k -ar 96000 -f flv rtmp://{DOMAIN}:1935/app/stream

Accesssing via wss://{DOMAIN}:3333/app/stream

(3333 is being used for TLS, 3334 is being used for non-TLS, I know that the port numbers are swapped :) )

{DOMAIN} in all logs is a publicly accessible domain like "live.domain.com"

sephentos commented 3 years ago

I accidentally closed the issue while creating my answer. Sorry for that.

https://github.com/AirenSoft/OvenMediaEngine/issues/282#issuecomment-782188848

getroot commented 3 years ago

@sephentos Can I ssh to your server and check it out? If possible, send access information to dev@airensoft.com. I would like to analyze this case and share it with others.

sephentos commented 3 years ago

@getroot

@sephentos Can I ssh to your server and check it out? If possible, send access information to dev@airensoft.com. I would like to analyze this case and share it with others.

Unfortunately I can't provide you ssh access due to sensitive nature. But I can tell you that I've got a new result. I've opened a new issue since its subject is different than this and this thread is also getting mussy.

See #295 for more.