AlexxIT/go2rtc · error

multipart: no receivers

Error message

multipart: no receivers

What it means

Producer.Start (labeled with the 'multipart:' prefix despite living in pkg/kasa) requires at least one receiver configured before it can begin producing. If the Producer's Receivers slice is empty, it refuses to start and returns this error. It is a configuration precondition check, not a runtime/network failure.

Solutions

  1. Create at least one core.Receiver (video and/or audio) and append it to Producer.Receivers before calling Start().
  2. Verify the code path that builds the Producer actually registers receivers (check for skipped media config entries).
  3. Log len(prod.Receivers) before Start() to confirm configuration is applied.

Example fix

// before
prod := kasa.NewProducer(...)
err := prod.Start() // panic-free but fails: multipart: no receivers
// after
recv := core.NewReceiver(core.FormatH264, nil)
prod.Receivers = append(prod.Receivers, recv)
err := prod.Start()
Defensive patterns

Strategy: validation

Validate before calling

if len(prod.Receivers) == 0 {
	return errors.New("cannot start producer: no receivers configured")
}
err := prod.Start()

Type guard

func hasReceivers(p *kasa.Producer) bool { return p != nil && len(p.Receivers) > 0 }

Try / catch

if err := prod.Start(); err != nil {
	if err.Error() == "multipart: no receivers" {
		return fmt.Errorf("producer misconfigured: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling Producer.Start() on a Producer constructed without appending any *core.Receiver to c.Receivers (e.g. no video/audio receivers were configured).

Common situations: Forgot to wire receivers after creating the Producer; receivers were attached to the wrong Producer instance; config parsing skipped media entries so none were added.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at pkg/kasa/producer.go:85

	prod := &Producer{
		Connection: core.Connection{
			ID:         core.NewID(),
			FormatName: "kasa",
			Protocol:   "http",
			Transport:  rd,
		},
		rd: core.NewReadBuffer(rd),
	}
	if err = prod.probe(); err != nil {
		return nil, err
	}
	return prod, nil
}

func (c *Producer) Start() error {
	if len(c.Receivers) == 0 {
		return errors.New("multipart: no receivers")
	}

	var video, audio *core.Receiver

	for _, receiver := range c.Receivers {
		switch receiver.Codec.Name {
		case core.CodecH264:
			video = receiver
		case core.CodecPCMU:
			audio = receiver
		}
	}

	for {
		header, body, err := mpjpeg.Next(c.reader)
		if err != nil {
			return err
		}

View on GitHub (pinned to c245815e75)