AlexxIT/go2rtc · error

can't find consumer

Error message

can't find consumer

What it means

Play returns this when it cannot find the internal consumer it needs to bridge an external producer into the stream — the loop over the stream's consumers ended without a match. It is a lookup failure inside the swap/replay logic, typically because the expected internal consumer was already removed or never added.

Solutions

  1. Check that the internal consumer was added before Play is called and not concurrently removed
  2. Guard Play calls with the stream mutex or check stream state first
  3. Retry the play operation after re-adding the consumer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/streams/play.go:108 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/be7a788cc7db698a. Report an issue: GitHub.

Appendix: source

Thrown at internal/streams/play.go:108

		go func() {
			_ = dst.Start()
			_ = src.Stop()
			s.RemoveInternalConsumer(cons)
		}()

		go func() {
			_ = src.Start()
			// little timeout before stop dst, so the buffer can be transferred
			time.Sleep(time.Second)
			_ = dst.Stop()
			s.RemoveProducer(src)
		}()

		return nil
	}

	return errors.New("can't find consumer")
}

func (s *Stream) AddInternalProducer(conn core.Producer) {
	producer := &Producer{conn: conn, state: stateInternal, url: "internal"}
	s.mu.Lock()
	s.producers = append(s.producers, producer)
	s.mu.Unlock()
}

func (s *Stream) AddInternalConsumer(conn core.Consumer) {
	s.mu.Lock()
	s.consumers = append(s.consumers, conn)
	s.mu.Unlock()
}

func (s *Stream) RemoveInternalConsumer(conn core.Consumer) {
	s.mu.Lock()
	for i, consumer := range s.consumers {

View on GitHub (pinned to c245815e75)