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.57k stars 1.06k forks source link

LLHLS Publisher - Connections remain open until window is closed #1304

Closed bchah closed 1 year ago

bchah commented 1 year ago

Describe the bug When viewing with the LLHLS publisher, every time you reload the stream or navigate away then back, a new connection is established but the old connection seems to not be destroyed. There is no data flowing through the old connections but they seem to persist until the window is closed.

To Reproduce Open an LLHLS stream then reload the page. In the attached logs I did this 10 times and it shows each new connection. When you actually close the window or quit your browser, then the 10 connections will all be destroyed.

Expected behavior Each client should only use one connection per stream. If they have an open connection to the stream already that should be re-used or destroyed before a new one is created.

Logs log.txt

Server (please complete the following information): Docker dev latest

Player (please complete the following information): Google Chrome and Safari on macOS

getroot commented 1 year ago

This is a feature of HTTP/2.0. HTTP/2.0 browsers establish and reuse a single connection to the same server. Therefore, in OME, there is no way to know if the existing LLHLS session has been terminated until the connection of the same device is completely disconnected. However, since OME can estimate whether a new LLHLS session is connected from the same device (existing TCP connection) by seeing the request for the master playlist, it determines that the LLHLS session has been added. And when the HTTP2.0/TCP connection is completely closed, OME determines that all existing sessions on that connection are closed.

This only affects the counting of LLHLS concurrent connection sessions. Also, since there are not that many cases of establishing multiple sessions on one device in the real world, there will be no big error in the number of concurrent users.

bchah commented 1 year ago

Thanks @getroot and I understand the technology trap presented here by HTTP/2.0. I have had customers asking because it looks like there is an unauthorized viewer of the stream when they see the viewer count changing. It is common that a user might go watch one stream, then navigate to another, and back to the first stream over the course of a session.

I might revisit this as a feature request on the discussions board. Recently Keukhan added the "DeleteLazyStream" option which looks for live streams with no data being passed and deletes them after a certain time interval. I wonder if we could observe LLHLS sessions where there is data moving in the stream but no data is being passed to the session, and delete them (something like "DeleteLazySession").