Glimesh / janus-ftl-plugin

A plugin for the Janus WebRTC gateway to enable relaying of audio/video streams utilizing Mixer's FTL (Faster-Than-Light) protocol.
https://hayden.fyi/posts/2020-08-03-Faster-Than-Light-protocol-engineering-notes.html
GNU Affero General Public License v3.0
46 stars 11 forks source link

Intermittent crashes when restarting a stream immediately after stopping it #38

Closed danstiner closed 3 years ago

danstiner commented 3 years ago

To reproduce, open OBS and spam the start/stop streaming button until the janus server terminates.

Per the title, This seems to specifically be from starting a FTL stream again immediately after stopping it. The server will terminate and print the following output:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  Attempt to add FTL Stream with a channel ID that is already assigned.

This seems to be from a reasonable exception that should just be caught further up the stack instead of terminating the entire server: https://github.com/Glimesh/janus-ftl-plugin/blob/8b898956ba160ddd83a030f6c8eea809b7b21780/FtlStreamStore.cpp#L28-L32

Discovered while testing file descriptor leaks (#18) by starting and stopping streaming in OBS a bunch.

haydenmc commented 3 years ago

Good bug!

Yeah, I think the ideal behavior would be to either terminate the new connection, or terminate the existing one. I lean toward the latter, as I imagine the common case is OBS trying to reconnect before the old connection has finished timing out.

haydenmc commented 3 years ago

60 will now terminate existing connections on the same channel if a new stream starts.