AlexxIT/go2rtc · error

webRTCConfigResponse.Msg

Error message

webRTCConfigResponse.Msg

What it means

This error surfaces the API-level error message (Msg field) returned by the Tuya cloud when the WebRTC config endpoint responds with Success=false. The library unmarshals the HTTP body successfully but the Tuya CloudOpen API rejected the request, so the server's own message is wrapped and returned as a Go error from loadWebrtcConfig. It indicates an application-level API rejection (bad credentials, wrong device/region), not a transport or JSON failure.

Solutions

  1. Verify accessId/accessSecret and that the token was fetched successfully; re-run Init after refreshing credentials
  2. Check the region base URL matches the Tuya data center where the device is registered
  3. Confirm the device ID is correct and the device supports WebRTC in the Tuya IoT platform
  4. Log the raw response body to see the full Tuya error code/message for the exact cause

Example fix

// before
cfg, err := client.Init()
if err != nil { log.Fatal(err) }
// after
cfg, err := client.Init()
if err != nil {
    if strings.Contains(err.Error(), "invalid token") || strings.Contains(err.Error(), "sign") {
        log.Fatalf("Tuya credential/region problem, check accessId/secret/region: %v", err)
    }
    log.Fatalf("init failed: %v", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before Init: verify config fields are non-empty
if accessID == "" || accessSecret == "" || regionURL == "" { return errors.New("missing tuya cloud config") }

Try / catch

cfg, err := client.Init()
if err != nil {
    // Tuya API rejections are surfaced verbatim; log and abort or refresh creds
    log.Printf("webrtc config load failed: %v", err)
    return err
}

Prevention

When it happens

Trigger: Init() -> loadWebrtcConfig() calls the Tuya cloud WebRTC config endpoint and the response JSON has Success=false; the Msg string from Tuya becomes this error. Typical causes: invalid accessId/accessSecret, wrong region base URL, expired or invalid token, or the device not supporting WebRTC.

Common situations: Developers hit this when credentials in config are stale or rotated, when the region endpoint (e.g. EU vs China vs US) doesn't match where the device is registered, or when the device model has no WebRTC skill on the cloud side.

Related errors


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

Appendix: source

Thrown at pkg/tuya/cloud_api.go:211

	return nil
}

func (c *TuyaCloudApiClient) loadWebrtcConfig() (*WebRTCConfig, error) {
	url := fmt.Sprintf("https://%s/v1.0/users/%s/devices/%s/webrtc-configs", c.baseUrl, c.uid, c.deviceId)

	body, err := c.request("GET", url, nil)
	if err != nil {
		return nil, err
	}

	var webRTCConfigResponse WebRTCConfigResponse
	err = json.Unmarshal(body, &webRTCConfigResponse)
	if err != nil {
		return nil, err
	}

	if !webRTCConfigResponse.Success {
		return nil, fmt.Errorf(webRTCConfigResponse.Msg)
	}

	err = json.Unmarshal([]byte(webRTCConfigResponse.Result.Skill), &c.skill)
	if err != nil {
		return nil, err
	}

	// Store LocalKey (not sure if cloud api provides this, but we need it for low power cameras)
	c.localKey = webRTCConfigResponse.Result.LocalKey

	iceServers, err := json.Marshal(&webRTCConfigResponse.Result.P2PConfig.Ices)
	if err != nil {
		return nil, err
	}

	c.iceServers, err = webrtc.UnmarshalICEServers(iceServers)
	if err != nil {
		return nil, err

View on GitHub (pinned to c245815e75)