AlexxIT/go2rtc · error

enable return audio

Error message

enable return audio: %w

What it means

StartIntercom sends a K10010 control message to enable return audio and waits up to 5 seconds for the KCmdControlChannelResp IO control reply. If WriteAndWaitIOCtrl fails (write error, timeout, or camera refusing the channel), the error is wrapped with this prefix.

Solutions

  1. Inspect the wrapped error to distinguish timeout vs write failure; retry StartIntercom after a short delay on timeout.
  2. Verify the camera model supports two-way audio (return audio) and firmware is up to date.
  3. Check network stability; re-establish the session with Dial + doAVLogin if the socket is dead.
  4. Increase patience around the call — check IsBackchannelReady after retry before writing audio.

Example fix

// before
if err := client.StartIntercom(); err != nil {
    panic(err)
}

// after
if err := client.StartIntercom(); err != nil {
    // likely timeout or camera offline; reconnect and retry once
    if derr := client.Dial(); derr == nil {
        err = client.StartIntercom()
    }
    if err != nil {
        return fmt.Errorf("intercom unavailable: %w", err)
    }
}
Defensive patterns

Strategy: retry

Validate before calling

if !client.IsConnected() {
    return fmt.Errorf("not connected")
}

Try / catch

if err := client.StartIntercom(); err != nil {
    if errors.Is(err, context.DeadlineExceeded) || strings.Contains(err.Error(), "enable return audio") {
        time.Sleep(2 * time.Second)
        err = client.StartIntercom()
    }
    if err != nil {
        return fmt.Errorf("intercom setup failed: %w", err)
    }
}

Prevention

When it happens

Trigger: DTLS/AV channel dropped mid-session; camera firmware rejects or ignores the K10010 enable-return-audio request; 5s IO-ctrl timeout expires because the camera is busy or offline; write fails because the underlying socket is closed.

Common situations: Camera went offline or lost Wi-Fi during a session; firmware that does not support two-way audio; slow/unreliable networks causing the 5s timeout; calling intercom immediately after connect before the camera is ready.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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

Appendix: source

Thrown at pkg/wyze/client.go:215

func (c *Client) StartAudio() error {
	k10010 := c.buildK10010(MediaTypeAudio, true)
	_, err := c.conn.WriteAndWaitIOCtrl(k10010, c.matchHL(KCmdControlChannelResp), 5*time.Second)
	return err
}

func (c *Client) StartIntercom() error {
	if c.conn == nil {
		return fmt.Errorf("connection is nil")
	}

	if c.conn.IsBackchannelReady() {
		return nil
	}

	k10010 := c.buildK10010(MediaTypeReturnAudio, true)
	if _, err := c.conn.WriteAndWaitIOCtrl(k10010, c.matchHL(KCmdControlChannelResp), 5*time.Second); err != nil {
		return fmt.Errorf("enable return audio: %w", err)
	}

	if c.verbose {
		fmt.Printf("[Wyze] Speaker channel enabled, waiting for readiness...\n")
	}

	return c.conn.AVServStart()
}

func (c *Client) StopIntercom() error {
	if c.conn == nil || !c.conn.IsBackchannelReady() {
		return nil
	}

	k10010 := c.buildK10010(MediaTypeReturnAudio, false)
	c.conn.WriteIOCtrl(k10010)

	return c.conn.AVServStop()

View on GitHub (pinned to c245815e75)