-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Which version are you using?
MediaMTX v1.15.4
Which operating system are you using?
Linux amd64 Docker
Describe the issue
When I try to connect to my Bambu H2S 3D printer, MediaMTX gets stuck in a 301 redirect loop. The source is defined as rtsps://bblp:{{ printer.code }}@{{ printer.ip }}:322/streaming/live/1, however MediaMTX sends an OPTIONS rtsp://192.168.178.22:322/streaming/live/1 RTSP/1.0 (note the rtsp instead of rtsps).
As a result, the printer just replies with a RTSP/1.0 301 Moved Permanently and Location: rtsps://192.168.178.22/1 – and MediaMTX sends another OPTIONS rtsp://192.168.178.22:322/streaming/live/1 RTSP/1.0.
I've compared this to a pcap from ffplay and found that ffplay uses OPTIONS rtsp://... – which does not result in a redirect, but yields a working stream.
Describe how to replicate the issue
- Start the MediaMTX with
logLevel: debug paths: printer: rtspTransport: tcp source: rtsps://bblp:{{ printer.code }}@{{ printer.ip }}:322/streaming/live/1 sourceFingerprint: {{ printer.cert }}
– the errors should appear in the log immediately.
As a comparison, the decrypted pcap from ffplay:
OPTIONS rtsps://192.168.178.22:322/streaming/live/1 RTSP/1.0
CSeq: 1
User-Agent: Lavf62.3.100
RTSP/1.0 200 OK
CSeq: 1
Date: Sun, Nov 30 2025 23:23:44 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
DESCRIBE rtsps://192.168.178.22:322/streaming/live/1 RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf62.3.100
RTSP/1.0 401 Unauthorized
CSeq: 2
Date: Sun, Nov 30 2025 23:23:44 GMT
WWW-Authenticate: Digest realm="LIVE555 Streaming Media", nonce="72aad7c1850fc0d330953c0385cf4054"
DESCRIBE rtsps://192.168.178.22:322/streaming/live/1 RTSP/1.0
Accept: application/sdp
CSeq: 3
User-Agent: Lavf62.3.100
Authorization: Digest username="bblp", realm="LIVE555 Streaming Media", nonce="72aad7c1850fc0d330953c0385cf4054", uri="rtsps://192.168.178.22:322/streaming/live/1", response="c896b3d8b81b6e7dc49ddebf722c1bf2"
RTSP/1.0 200 OK
CSeq: 3
Date: Sun, Nov 30 2025 23:23:44 GMT
Content-Base: rtsps://192.168.178.22/streaming/live/1/
Content-Type: application/sdp
Content-Length: 497
v=0
o=- 1764533315220944 1 IN IP4 192.168.178.22
s=rtsp stream server
i=Mon Dec 1 04:08:35 2025
t=0 0
a=tool:LIVE555 Streaming Media v2023.03.30
a=type:broadcast
a=control:*
a=range:npt=now-
a=x-qt-text-nam:rtsp stream server
a=x-qt-text-inf:Mon Dec 1 04:08:35 2025
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:1000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=64C029;sprop-parameter-sets=Z2TAKawbGqBpAiflmyAAAAMAIAAAB5HhEI1A,aO4xshs=
a=control:track1
SETUP rtsps://192.168.178.22/streaming/live/1/track1 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
CSeq: 4
User-Agent: Lavf62.3.100
Authorization: Digest username="bblp", realm="LIVE555 Streaming Media", nonce="72aad7c1850fc0d330953c0385cf4054", uri="rtsps://192.168.178.22/streaming/live/1/track1", response="af45a045b0f8dccd30d8ae2ec229a0a5"
RTSP/1.0 200 OK
CSeq: 4
Date: Sun, Nov 30 2025 23:23:44 GMT
Transport: RTP/AVP/TCP;unicast;destination=192.168.178.33;source=192.168.178.22;interleaved=0-1
Session: F643101D;timeout=10
PLAY rtsps://192.168.178.22/streaming/live/1/ RTSP/1.0
Range: npt=0.000-
CSeq: 5
User-Agent: Lavf62.3.100
Session: F643101D
Authorization: Digest username="bblp", realm="LIVE555 Streaming Media", nonce="72aad7c1850fc0d330953c0385cf4054", uri="rtsps://192.168.178.22/streaming/live/1/", response="9c1ca84f5849ec48b716943440e5b4a2"
$..,....F.2y..P..t...v..............F.2y..O1S...RTSP/1.0 200 OK
CSeq: 5
Date: Sun, Nov 30 2025 23:23:44 GMT
Range: npt=0.000-
Session: F643101D
RTP-Info: url=rtsps://192.168.178.22/streaming/live/1/track1;seq=30320;rtptime=3413573149
<begin of binary packets>Regarding how to reproduce, I'm not sure how to do that without the specific device, as I don't know which server they use, or if there is a server out there that behaves the same.
MediaMTX configuration
logLevel: debug
paths:
printer:
rtspTransport: tcp
source: rtsps://bblp:{{ printer.code }}@{{ printer.ip }}:322/streaming/live/1
sourceFingerprint: {{ printer.cert }}MediaMTX logs
mediamtx-1 | 2025/12/01 00:59:22 INF MediaMTX v1.15.4
mediamtx-1 | 2025/12/01 00:59:22 INF configuration loaded from /mediamtx.yml
mediamtx-1 | 2025/12/01 00:59:22 DEB [path printer] created
mediamtx-1 | 2025/12/01 00:59:22 DEB path manager created
mediamtx-1 | 2025/12/01 00:59:22 INF [path printer] [RTSP source] started
mediamtx-1 | 2025/12/01 00:59:22 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
mediamtx-1 | 2025/12/01 00:59:22 INF [RTMP] listener opened on :1935
mediamtx-1 | 2025/12/01 00:59:22 DEB [path printer] [RTSP source] connecting
mediamtx-1 | 2025/12/01 00:59:22 INF [HLS] listener opened on :8888
mediamtx-1 | 2025/12/01 00:59:22 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP)
mediamtx-1 | 2025/12/01 00:59:22 INF [SRT] listener opened on :8890 (UDP)
mediamtx-1 | 2025/12/01 00:59:22 DEB [path printer] [RTSP source] [c->s] OPTIONS rtsp://192.168.178.22:322/streaming/live/1 RTSP/1.0
mediamtx-1 | CSeq: 1
mediamtx-1 | User-Agent: gortsplib
mediamtx-1 |
mediamtx-1 |
mediamtx-1 | 2025/12/01 00:59:22 DEB [path printer] [RTSP source] [s->c] RTSP/1.0 301 Moved Permanently
mediamtx-1 | CSeq: 1
mediamtx-1 | Date: Mon, Dec 01 2025 00:24:44 GMT
mediamtx-1 | Location: rtsps://192.168.178.22/1
mediamtx-1 |
mediamtx-1 |
mediamtx-1 | 2025/12/01 00:59:22 ERR [path printer] [RTSP source] bad status code: 301 (Moved Permanently)
mediamtx-1 | 2025/12/01 00:59:27 DEB [path printer] [RTSP source] connecting
mediamtx-1 | 2025/12/01 00:59:27 DEB [path printer] [RTSP source] [c->s] OPTIONS rtsp://192.168.178.22:322/streaming/live/1 RTSP/1.0
mediamtx-1 | CSeq: 1
mediamtx-1 | User-Agent: gortsplib
mediamtx-1 |
mediamtx-1 |
mediamtx-1 | 2025/12/01 00:59:28 DEB [path printer] [RTSP source] [s->c] RTSP/1.0 301 Moved Permanently
mediamtx-1 | CSeq: 1
mediamtx-1 | Date: Mon, Dec 01 2025 00:24:49 GMT
mediamtx-1 | Location: rtsps://192.168.178.22/1
mediamtx-1 |
mediamtx-1 |
mediamtx-1 | 2025/12/01 00:59:28 ERR [path printer] [RTSP source] bad status code: 301 (Moved Permanently)Network dump
I have omitted the PCAP file, as it is TLS encrypted and MediaMTX doesn't implement SSLKEYLOGFILE, so the dump cannot be used for debugging; there is no way to connect to the server without TLS.