Skip to content

Mediamtx sometimes fails on startup - rpicam, autostart #5019

@leeprevost

Description

@leeprevost

Which version are you using?

v1.15.0

Which operating system are you using?

Linux arm64 standard

Describe the issue

I have added mediamtx as a systemctl unit in startup following the guide linux/boot. Occasionally, I have found the server starts but when a client browser is already waiting, the server fails to start properly as indicated by this condition in the logs:

Sep 22 08:42:46 raspberrypi mediamtx[422]: 2025/09/22 08:42:46 INF [WebRTC] [session 725f22de] created by 192.168.1.218:63802
Sep 22 08:42:56 raspberrypi mediamtx[422]: 2025/09/22 08:42:56 INF [WebRTC] [session 725f22de] closed: deadline exceeded while waiting connection
Sep 22 08:43:04 raspberrypi mediamtx[422]: 2025/09/22 08:43:04 INF [WebRTC] [session 730c725f] created by 192.168.1.218:63802
Sep 22 08:43:14 raspberrypi mediamtx[422]: 2025/09/22 08:43:14 INF [WebRTC] [session 730c725f] closed: deadline exceeded while waiting connection
Sep 22 08:43:22 raspberrypi mediamtx[422]: 2025/09/22 08:43:22 INF [WebRTC] [session 7469222d] created by 192.168.1.218:63802
Sep 22 08:43:32 raspberrypi mediamtx[422]: 2025/09/22 08:43:32 INF [WebRTC] [session 7469222d] closed: deadline exceeded while waiting connection
Sep 22 08:43:40 raspberrypi mediamtx[422]: 2025/09/22 08:43:40 INF [WebRTC] [session 0f42ecdc] created by 192.168.1.218:63802
Sep 22 08:43:50 raspberrypi mediamtx[422]: 2025/09/22 08:43:50 INF [WebRTC] [session 0f42ecdc] closed: deadline exceeded while waiting connection
Sep 22 08:43:58 raspberrypi mediamtx[422]: 2025/09/22 08:43:58 INF [WebRTC] [session c3d85bc9] created by 192.168.1.218:63802
Sep 22 08:44:08 raspberrypi mediamtx[422]: 2025/09/22 08:44:08 INF [WebRTC] [session c3d85bc9] closed: deadline exceeded while waiting connection
Sep 22 08:44:16 raspberrypi mediamtx[422]: 2025/09/22 08:44:16 INF [WebRTC] [session ef14e307] created by 192.168.1.218:63802
Sep 22 08:44:26 raspberrypi mediamtx[422]: 2025/09/22 08:44:26 INF [WebRTC] [session ef14e307] closed: deadline exceeded while waiting connection

I'm wondering if it is starting too early (ie. some other target state) or if mediamtx has proper timing with respect to underlying camera handlers.

I can clear this easily with a simple restart:
systemctl restart mediamtx

Describe how to replicate the issue

  1. start the MediaMTX in systemctl
  2. publish with webrtc
  3. read with rpicam

MediaMTX configuration

my config:

api: yes
rtmp: no
hls: yes
srt: no
playback: yes
#webrtcEncryption: yes
#webrtcServerKey: /home/pi/camzero2/certs/raspberrypi+3-key.pem
#webrtcServerCert: /home/pi/camzero2/certs/raspberrypi+3.pem

paths:
  cam:
    source: rpiCamera
    #runOnDemand: python3 /home/pi/camzero2/camera/rtsp_stream.py
    recordPath: /home/pi/recordings/%path/%Y-%m-%d_%H-%M-%S-%f
    rpiCameraWidth: 800
    rpiCameraHeight: 600
    rpiCameraBitrate: 5000000

MediaMTX logs

No response

Network dump

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions