AlexxIT/go2rtc · error

webrtc: stream not found

Error message

webrtc: stream not found

What it means

Webtorrent tracker Exchange callback guard: the tracker requested an SDP exchange for a stream name that streams.Get cannot find (nil), so api.StreamNotFound ('webrtc: stream not found') is returned to the tracker. It means the share/announce referenced an unknown source, not that WebRTC itself failed.

Solutions

  1. Confirm the stream exists and is running before peers try to fetch it via the tracker
  2. Check the stream name embedded in the webtorrent share URL/announce
  3. Re-add or preload the missing stream, then let the peer retry the exchange
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/webtorrent/init.go:48 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/7fa1dc9b7d1468f3. Report an issue: GitHub.

Appendix: source

Thrown at internal/webtorrent/init.go:48

	app.LoadConfig(&cfg)

	if len(cfg.Mod.Trackers) == 0 {
		return
	}

	log = app.GetLogger("webtorrent")

	streams.HandleFunc("webtorrent", streamHandle)

	api.HandleFunc("api/webtorrent", apiHandle)

	srv = &webtorrent.Server{
		URL: cfg.Mod.Trackers[0],
		Exchange: func(src, offer string) (answer string, err error) {
			stream := streams.Get(src)
			if stream == nil {
				return "", errors.New(api.StreamNotFound)
			}
			return webrtc.ExchangeSDP(stream, offer, "webtorrent", "")
		},
	}

	if log.Debug().Enabled() {
		srv.Listen(func(msg any) {
			switch msg.(type) {
			case string, error:
				log.Debug().Msgf("[webtorrent] %s", msg)
			case *webtorrent.Message:
				log.Trace().Any("msg", msg).Msgf("[webtorrent]")
			}
		})
	}

	for name, share := range cfg.Mod.Shares {
		if len(name) < 8 {

View on GitHub (pinned to c245815e75)