OBS with Nginx server stops working after clients connect

samfisher5986

New Member
Hi Everyone

I've successfully run my nginx obs live stream locally but I've run into a problem.

There seems to be a chance, especially on first run that it will stop working after 5+ users connect and. Most of the time when I click "start live stream" again, it will keep going without issues and 15+ people can connect without issues. Its hard to make it happen on purpose though.

Nginx and OBS itself does not crash, but the live stream shows 0 kbps and a red icon, instead of 3000kbps and a green icon.

My keyframe interval is 2, my resolution is 720p and I have a lot of spare computer power (AMD 3900x and Nvidia 2060)

I feel like its something network related because it seems to happen when people join, its generally only using 40mbit of my 1000mbit gigabit lan connection though.

Has anyone run into anything similar? Is there something I can do to make it run more reliably?

I ran the "Tweak-Optimize tcpip parameters for nginx connections.reg" that came with it, but now I'm wondering if I should increase the limits higher, they already seem very high though.

-------

Here is my log for the period where it stopped working. It does show dropped frames, but some users are watching via wifi etc so that should be their end.

9:06:30 AM.646: [ffmpeg muxer: 'adv_file_output'] Output of file 'D:/OBS Recordings/2020-05-28 08-57-14.mkv' stopped
9:06:30 AM.646: Output 'adv_file_output': stopping
9:06:30 AM.646: Output 'adv_file_output': Total frames output: 16630
9:06:30 AM.646: Output 'adv_file_output': Total drawn frames: 16677
9:06:30 AM.647: ==== Recording Stop ================================================
9:06:30 AM.647: warning: 2 frames left in the queue on closing
9:06:34 AM.733: [rtmp stream: 'adv_stream'] User stopped the stream
9:06:34 AM.733: Output 'adv_stream': stopping
9:06:34 AM.733: Output 'adv_stream': Total frames output: 16443 (17712 attempted)
9:06:34 AM.733: Output 'adv_stream': Total drawn frames: 17749
9:06:34 AM.733: Output 'adv_stream': Number of dropped frames due to insufficient bandwidth/connection stalls: 1269 (7.2%)
9:06:34 AM.733: [rtmp stream: 'adv_stream'] Freeing 210 remaining packets
9:06:34 AM.737: ==== Streaming Stop ================================================
9:06:34 AM.770: warning: 2 frames left in the queue on closing
9:06:38 AM.490: ---------------------------------
9:06:38 AM.490: [x264 encoder: 'streaming_h264'] preset: veryfast
9:06:38 AM.490: [x264 encoder: 'streaming_h264'] settings:
9:06:38 AM.490: rate_control: CBR
9:06:38 AM.490: bitrate: 3000
9:06:38 AM.490: buffer size: 3000
9:06:38 AM.490: crf: 0
9:06:38 AM.490: fps_num: 30
9:06:38 AM.490: fps_den: 1
9:06:38 AM.490: width: 1280
9:06:38 AM.490: height: 720
9:06:38 AM.490: keyint: 60
9:06:38 AM.490:
9:06:38 AM.494: ---------------------------------
9:06:38 AM.494: [FFmpeg aac encoder: 'Track1'] bitrate: 160, channels: 2, channel_layout: 3
9:06:38 AM.494:
 

FerretBomb

Active Member
Those dropped frames are on your end. Those are dropped frames from OBS to the nginx server, not from nginx to viewers. Dropped frames are always a network problem between you and the server.
If the bitrate is dropping to zero and staying there, try turning off the adaptive bandwidth reduction option; it seems to error out sometimes and present in that manner. You'll just need to run within the bandwidth constraints of your connection's worst throughput, and adjust your bitrate (and framerate/resolution possibly, to maintain image quality) accordingly.

Users are not connecting to OBS. They are connecting to the nginx server. OBS does not care how many people are watching from your nginx server; it doesn't even know how many are watching. It just provides a single video stream feed to the server.
Any issues between the server and your viewers are an nginx problem; we cannot help with that, nginx is outside the scope of OBS support.

We'll generally be able to provide more comprehensive analysis with a complete logfile, rather than just a snip, by the by.
 

samfisher5986

New Member
The dropped frames are expected as some people are on wireless, that shouldn't cause the stream to stop should it?

I tried disabling network optimisations and TCP pacing but it didn't work.

I managed to crash the stream quite easily today, one LAN client connected for 1 hour without issues, 1 wireless client connected and it crashed before I could even view it on that client.

I checked both OBS logs and nginx error.log and there are no events after the stream stops transmitting.

I understand its unlikely an OBS issue exactly but I figure others here are using OBS + Nginx so might be able to help.

I've checked the nginx rtmp github but wasn't able to find a good place to get some help.

I have attached the log file where the stream stopped working.
 

Attachments

  • obs log - 2020-06-04 08-43-46.txt
    9.5 KB · Views: 12

samfisher5986

New Member
Small update (sorry can't seem to edit post)

If I start a fresh OBS and Nginx, connect some wireless clients and then wait for one of them to make the stream fail, I then force close OBS (as it won't close anymore) and then start it up again and start streaming, it appears to be very stable.

I'm not sure what this means in terms of who is at fault, OBS or Nginx.
 
Last edited:

Mark Weiss

Member
I've been tackling this problem for the past month as well. Windows 10 OBS 27 and OBS 28 both tried. Streaming over a wired CAT6 connection to another Windows 10 server box running nginx on port 8080. It works, but at random times--could be minutes, could be hours-- OBS stream drops to zero and indicator goes red. I can often 'wake' OBS by opening a browser with the stream URL and refresh the page. I don't see how a client of nginx an 'wake' or affect OBS which is streaming to nginx, but there it is.
I've rebooted the routers, checked the cables (genuine CAT6 and interfaces at 1gb/s speed), looked for updated LAN driver (none available). Now I'm playing with LAN adapter settings.
The odd thing is I can stream to youtube, facebook and twitch using multiple output plugin with no dropped frames for hours, so the internet (gig fiber) is solid. But just streaming to a computer that is inches away keeps failing at random!

1664666962428.png
 

Mark Weiss

Member
Someone suggested testing streaming with monaserver instead of nginx. I did so today and found that OBS maintained a steady stream. I was even able to try extreme bitrates. To stress the system, I tried streaming at 92mbit/sec. OBS streamed perfectly to monaserver with no dropped frames. I've also run network throughput testing with iperf. I got 940mb/s on that test run.
This suggests that my network infrastructure is robust and that the problem is nginx Griffon build. Which can't reliably handle even 2mbit/sec stream. It does this dropout even with no users connected.
 
Top