AlexxIT/go2rtc · error

wrong RTSP conn mode

Error message

wrong RTSP conn mode: %d

What it means

Handle was invoked on a connection whose mode is not one of the supported RTSP modes (active producer/consumer, passive producer/consumer), so timeout handling cannot be configured. Indicates an internal state bug — the mode value is printed.

Solutions

  1. Set a valid mode (ModePassiveProducer, ModePassiveConsumer, etc.) on the connection before Handle
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/rtsp/conn.go:134 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/ed2a9d8a4ce369f5. Report an issue: GitHub.

Appendix: source

Thrown at pkg/rtsp/conn.go:134

			}
		} else {
			timeout = time.Second * time.Duration(c.Timeout)
		}

	case core.ModePassiveProducer:
		// polling frames from remote RTSP Client (ex FFmpeg)
		if c.Timeout == 0 {
			timeout = time.Second * 15
		} else {
			timeout = time.Second * time.Duration(c.Timeout)
		}

	case core.ModePassiveConsumer:
		// pushing frames to remote RTSP Client (ex VLC)
		timeout = time.Second * 60

	default:
		return fmt.Errorf("wrong RTSP conn mode: %d", c.mode)
	}

	for i := 0; i < len(c.udpConn); i++ {
		go c.handleUDPData(byte(i))
	}

	for c.state != StateNone {
		ts := time.Now()

		_ = c.conn.SetReadDeadline(ts.Add(timeout))

		if err = c.handleTCPData(); err != nil {
			return
		}
	}

	return
}

View on GitHub (pinned to c245815e75)