Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] rtmp url stuck after a while #241

Open
masternet0 opened this issue Jun 21, 2023 · 6 comments
Open

[bug] rtmp url stuck after a while #241

masternet0 opened this issue Jun 21, 2023 · 6 comments

Comments

@masternet0
Copy link

Hello,
I have weird issue with rtmp url its stuck and not responding after a while and to solve issue must be restart nginx force
for example
when I send stream from any encoder or from the same local server from ffmpeg to the nginx rtmp info it works properly on both rtmp and hls (m3u8) urls
after while rtmp stuck and not responding but the hls for m3u8 works properly without issue and need to restart force nginx to solve the issue with the rtmp url

*** and not any error log appear for this case its just stuck and not responding

also I tried to check the rtmp url on same local server with ffprobe command and also not responding
ffprobe -v quiet -print_format json -show_streams rtmp://127.0.0.1:2485/user1/user1

nginx version :
test on nginx version: nginx/1.22.1 and nginx version: nginx/1.18.0 both same issue

OS tested :
CentOS stream 8 and Ubuntu 22

any hint to how to check the reason specially not any thing appear with error logs related with this

Regards

@winshining
Copy link
Owner

Did you add directive drop_idle_publisher?
For example: drop_idle_publisher 30s. It drops idle (stuck) publishers resulted from network problems.

And the following is my test screenshot, no lag happened:

2023-07-07_12-26-47_screenshot

@masternet0
Copy link
Author

Hello,
Thank you for your response
the issue its random not appeared with all accounts and when appear its after few hours
I will add drop_idle_publisher 15s and watch what will happen

@hawolt
Copy link

hawolt commented Apr 1, 2024

I believe I am facing the same issue and I can't seem to figure out why its happening other than something getting stuck somewhere, sometimes it works, sometimes it doesnt; the drop_idle_publisher entry does not really seem to help

I use OBS to stream to rtmp://IPV4/encoder with a Stream Key, now sometimes just like for @masternet0 the rtmp url is not responding, I have yet to figure out how to fix it but it randomly starts working again after killing all connections and giving it 10-60 minutes

I have build ffmpeg myself

ffmpeg -version
ffmpeg version N-114545-g199c479b9a Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 12 (Debian 12.2.0-14)

I believe the issue is either with ffmpeg not being able to handle the rtmp stream properly or the rtmp module not responding at all for some reason

[AVFormatContext @ 0x5562a8656cc0] Opening 'rtmp://localhost/encoder/test' for reading
[rtmp @ 0x5562a86574c0] No default whitelist set
[tcp @ 0x5562a8657d80] No default whitelist set
[tcp @ 0x5562a8657d80] Original list of addresses:
[tcp @ 0x5562a8657d80] Address 127.0.0.1 port 1935
[tcp @ 0x5562a8657d80] Interleaved list of addresses:
[tcp @ 0x5562a8657d80] Address 127.0.0.1 port 1935
[tcp @ 0x5562a8657d80] Starting connection attempt to 127.0.0.1 port 1935
[tcp @ 0x5562a8657d80] Successfully connected to 127.0.0.1 port 1935
[rtmp @ 0x5562a86574c0] Handshaking...
[rtmp @ 0x5562a86574c0] Type answer 3
[rtmp @ 0x5562a86574c0] Server version 13.14.10.13
[rtmp @ 0x5562a86574c0] Proto = rtmp, path = /encoder/test, app = encoder, fname = test
[rtmp @ 0x5562a86574c0] Window acknowledgement size = 5000000
[rtmp @ 0x5562a86574c0] Max sent, unacked = 5000000
[rtmp @ 0x5562a86574c0] New incoming chunk size = 4000
[rtmp @ 0x5562a86574c0] Creating stream...
[rtmp @ 0x5562a86574c0] Sending play command for 'test'

my current config is the following, probably not relevant though

rtmp {
    server {
        listen 1935;
        chunk_size 4000;

        application encoder {
            live on;

            drop_idle_publisher 15s;

            exec ffmpeg -i rtmp://localhost/encoder/$name
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline rtmp://localhost/hls/720p2628kbs
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1000k -f flv -g 30 -r 30 -s 854x480 -preset superfast -profile:v baseline rtmp://localhost/hls/480p1128kbs
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 750k -f flv -g 30 -r 30 -s 640x360 -preset superfast -profile:v baseline rtmp://localhost/hls/360p878kbs
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 400k -f flv -g 30 -r 30 -s 426x240 -preset superfast -profile:v baseline rtmp://localhost/hls/240p528kbs
              -c:a libfdk_aac -b:a 64k -c:v libx264 -b:v 200k -f flv -g 15 -r 15 -s 426x240 -preset superfast -profile:v baseline rtmp://localhost/hls/240p264kbs;

             push rtmp://localhost/hls/1080p5120kbs;
        }

        application hls {
            live on;

            drop_idle_publisher 15s;

            hls on;
            hls_path /app/stream/hls;

            hls_nested on;
            hls_fragment_naming system;
            hls_playlist_length 10;
            hls_fragment 1;
            hls_type live;

            hls_variant _1080p5120kbs BANDWIDTH=5120000,RESOLUTION=1920x1080;
            hls_variant _720p2628kbs BANDWIDTH=2628000,RESOLUTION=1280x720;
            hls_variant _480p1128kbs BANDWIDTH=1128000,RESOLUTION=854x480;
            hls_variant _360p878kbs BANDWIDTH=878000,RESOLUTION=640x360;
            hls_variant _240p528kbs BANDWIDTH=528000,RESOLUTION=426x240;
            hls_variant _240p264kbs BANDWIDTH=264000,RESOLUTION=426x240;
        }
    }
}

OS: Linux 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
NGINX: nginx version: nginx/1.22.1

if any other information might be useful I can add it

edit: im not sure if this is relevant, but I feel like this exact same issue has been existing years ago if its the same thing, it also got stuck after sending the play instruction https://ffmpeg-user.ffmpeg.narkive.com/IkvMsQ56/ffmpeg-hangs-when-encoding-rtmp-input-stream

@masternet0
Copy link
Author

@hawolt @winshining
yes i'm still have this issue until now and not solved and drop_idle_publisher not help also no any errors or any thing appear to know the reason :(

@hawolt
Copy link

hawolt commented Apr 5, 2024

I had some more time to run some testing, it seems like the issue is actually not ffmpeg for this since VLC is unable to play the rtmp stream either, when ffmpeg works VLC will also work, I wrote a local rtmp client which also gets stuck waiting for data after the same rtmp message - so something is fauly in either nginx or the rtmp module; I'll stop communication here now and go to the original repo

@masternet0
Copy link
Author

I had some more time to run some testing, it seems like the issue is actually not ffmpeg for this since VLC is unable to play the rtmp stream either, when ffmpeg works VLC will also work, I wrote a local rtmp client which also gets stuck waiting for data after the same rtmp message - so something is fauly in either nginx or the rtmp module; I'll stop communication here now and go to the original repo

@hawolt
Yes I think the issue from the rtmp module its a bug
Also please If you find solution for this in the original repo send details to me
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants