Skip to content

[v1.11.2] - user session closed not detected anymore for webrtc stream #4204

@SixK

Description

@SixK

Which version are you using?

v1.11.2

Which operating system are you using?

Linux amd64 standard

Describe how to replicate the issue

We use mediamtx for webrtc clients with RTSP source and WHIP/WHEP session management.
With v1.9.3 when a user close a live stream, mediamtx detect session is closed and remove user from the room, then close RTSP stream (about 10 secondes after).
With v1.11.2, mediamtx don't detect session is closed so user is not removed from room and room is not closed.
This mean that stream still continue to play. (this is problematic as we use LTE network with limited data)

In v1.9.3 logs, we have thoses lines once live is stopped:

2025/01/27 12:32:56 INF [WebRTC] [session 715cd803] closed: peer connection closed
2025/01/27 12:33:06 INF [path 1319103550] [RTSP source] stopped: not needed by anyone

This never happen with v1.11.2.

In our application, we simply open a webrtc live stream, then close live about 2 seconds later.
(We don't use internal mediamtx player)

Server logs

Here are informations about rooms created (We use sourceOnDemand mode):

curl -vvv  http://localhost:9997/v3/config/paths/list
*   Trying 127.0.0.1:9997...
* Connected to localhost (127.0.0.1) port 9997 (#0)
> GET /v3/config/paths/list HTTP/1.1
> Host: localhost:9997
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Server: mediamtx
< Date: Mon, 27 Jan 2025 10:58:04 GMT
< Transfer-Encoding: chunked
< 
{"itemCount":2,"pageCount":1,"items":[{"name":"1319103536","source":"rtsp://192.168.1.217:1042/cam/realmonitor?channel=1\u0026subtype=1","sourceFingerprint":"","sourceOnDemand":true,"sourceOnDemandStartTimeout":"10s","sourceOnDemandCloseAfter":"10s","maxReaders":0,"srtReadPassphrase":"","fallback":"","record":false,"recordPath":"./recordings/%path/%Y-%m-%d_%H-%M-%S-%f","recordFormat":"fmp4","recordPartDuration":"1s","recordSegmentDuration":"1h0m0s","recordDeleteAfter":"1d","overridePublisher":true,"srtPublishPassphrase":"","rtspTransport":"tcp","rtspAnyPort":false,"rtspRangeType":"","rtspRangeStart":"","sourceRedirect":"","rpiCameraCamID":0,"rpiCameraWidth":1920,"rpiCameraHeight":1080,"rpiCameraHFlip":false,"rpiCameraVFlip":false,"rpiCameraBrightness":0,"rpiCameraContrast":1,"rpiCameraSaturation":1,"rpiCameraSharpness":1,"rpiCameraExposure":"normal","rpiCameraAWB":"auto","rpiCameraAWBGains":[0,0],"rpiCameraDenoise":"off","rpiCameraShutter":0,"rpiCameraMetering":"centre","rpiCameraGain":0,"rpiCameraEV":0,"rpiCameraROI":"","rpiCameraHDR":false,"rpiCameraTuningFile":"","rpiCameraMode":"","rpiCameraFPS":30,"rpiCameraAfMode":"continuous","rpiCameraAfRange":"normal","rpiCameraAfSpeed":"normal","rpiCameraLensPosition":0,"rpiCameraAfWindow":"","rpiCameraFlickerPeriod":0,"rpiCameraTextOverlayEnable":false,"rpiCameraTextOverlay":"%Y-%m-%d %H:%M:%S - MediaMTX","rpiCameraCodec":"auto","rpiCameraIDRPeriod":60,"rpiCameraBitrate":1000000,"rpiCameraProfile":"main","rpiCameraLevel":"4.1","runOnInit":"","runOnInitRestart":false,"runOnDemand":"","runOnDemandRestart":false,"runOnDemandStartTimeout":"10s","runOnDemandCloseAfter":"10s","runOnUnDemand":"","runOnReady":"","runOnReadyRestart":false,"runOnNotReady":"","runOnRead":"","runOnReadRestart":false,"runOnUnread":"","runOnRecordSegmentCreate":"","runOnRecordSegmentComplete":""},{"name":"all_others","source":"publisher","sourceFingerprint":"","sourceOnDemand":false,"sourceOnDemandStartTimeout":"10s","sourceOnDemandCloseAfter":"10s","maxReaders":0,"srtReadPassphrase":"","fallback":"","record":false,"recordPath":"./recordings/%path/%Y-%m-%d_%H-%M-%S-%f","recordFormat":"fmp4","recordPartDuration":"1s","recordSegmentDuration":"1h0m0s","recordDeleteAfter":"1d","overridePublisher":true,"srtPublishPassphrase":"","rtspTransport":"tcp","rtspAnyPort":false,"rtspRangeType":"","rtspRangeStart":"","sourceRedirect":"","rpiCameraCamID":0,"rpiCameraWidth":1920,"rpiCameraHeight":1080,"rpiCameraHFlip":false,"rpiCameraVFlip":false,"rpiCameraBrightness":0,"rpiCameraContrast":1,"rpiCameraSaturation":1,"rpiCameraSharpness":1,"rpiCameraExposure":"normal","rpiCameraAWB":"auto","rpiCameraAWBGains":[0,0],"rpiCameraDenoise":"off","rpiCameraShutter":0,"rpiCameraMetering":"centre","rpiCameraGain":0,"rpiCameraEV":0,"rpiCameraROI":"","rpiCameraHDR":false,"rpiCameraTuningFile":"","rpiCameraMode":"","rpiCameraFPS":30,"rpiCameraAfMode":"continuous","rpiCameraAfRange":"normal","rpiCameraAfSpeed":"normal","rpiCameraLensPosition":0,"rpiCameraAfWindow":"","rpiCameraFlickerPeriod":0,"rpiCameraTextOverlayEnable":false,"rpiCa* Connection #0 to host localhost left intact
meraTextOverlay":"%Y-%m-%d %H:%M:%S - MediaMTX","rpiCameraCodec":"auto","rpiCameraIDRPeriod":60,"rpiCameraBitrate":1000000,"rpiCameraProfile":"main","rpiCameraLevel":"4.1","runOnInit":"","runOnInitRestart":false,"runOnDemand":"","runOnDemandRestart":false,"runOnDemandStartTimeout":"10s","runOnDemandCloseAfter":"10s","runOnUnDemand":"","runOnReady":"","runOnReadyRestart":false,"runOnNotReady":"","runOnRead":"","runOnReadRestart":false,"runOnUnread":"","runOnRecordSegmentCreate":"","runOnRecordSegmentComplete":""}]}

Here is an exemple of room informations:
{"name":"1319103529","confName":"1319103529","source":{"type":"rtspSource","id":""},"ready":true,"readyTime":"2025-01-27T11:38:13.356284827+01:00","tracks":["H264"],"bytesReceived":37978603,"bytesSent":75691255,"readers":[{"type":"webRTCSession","id":"27206dfc-a5c2-4848-8ba6-4d5e03fa9a90"},{"type":"webRTCSession","id":"4b32a69a-308e-43af-857d-b2dfe92589fc"}]}

Network dump

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwebrtc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions