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

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

Closed
SixK opened this issue Jan 27, 2025 · 4 comments · Fixed by #4212
Closed

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

SixK opened this issue Jan 27, 2025 · 4 comments · Fixed by #4212
Labels
bug Something isn't working webrtc

Comments

@SixK
Copy link

SixK commented Jan 27, 2025

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

@aler9 aler9 added question Further information is requested webrtc bug Something isn't working and removed question Further information is requested labels Jan 31, 2025
@aler9
Copy link
Member

aler9 commented Jan 31, 2025

Thanks for reporting the issue, i was able to reproduce it by using Firefox to read a stream, this is caused by a bug introduced with #3899.

@aler9
Copy link
Member

aler9 commented Jan 31, 2025

The bug is not introduced with #3899, it's pion/webrtc that sets the peer connection as "closed" without Close() being called at all.

@aler9
Copy link
Member

aler9 commented Jan 31, 2025

fixed by #4212

Copy link
Contributor

github-actions bot commented Feb 7, 2025

This issue is mentioned in release v1.11.3 🚀
Check out the entire changelog by clicking here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working webrtc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants