{"record":{"id":"8fc6f4c06570b85f","repo":"AlexxIT/go2rtc","slug":"webrtcconfigresponse-msg-8fc6f4","errorCode":null,"errorMessage":"webRTCConfigResponse.Msg","messagePattern":"webRTCConfigResponse\\.Msg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/cloud_api.go","lineNumber":211,"sourceCode":"\treturn nil\n}\n\nfunc (c *TuyaCloudApiClient) loadWebrtcConfig() (*WebRTCConfig, error) {\n\turl := fmt.Sprintf(\"https://%s/v1.0/users/%s/devices/%s/webrtc-configs\", c.baseUrl, c.uid, c.deviceId)\n\n\tbody, err := c.request(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar webRTCConfigResponse WebRTCConfigResponse\n\terr = json.Unmarshal(body, &webRTCConfigResponse)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !webRTCConfigResponse.Success {\n\t\treturn nil, fmt.Errorf(webRTCConfigResponse.Msg)\n\t}\n\n\terr = json.Unmarshal([]byte(webRTCConfigResponse.Result.Skill), &c.skill)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Store LocalKey (not sure if cloud api provides this, but we need it for low power cameras)\n\tc.localKey = webRTCConfigResponse.Result.LocalKey\n\n\ticeServers, err := json.Marshal(&webRTCConfigResponse.Result.P2PConfig.Ices)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.iceServers, err = webrtc.UnmarshalICEServers(iceServers)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/cloud_api.go#L193-L229","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify accessId/accessSecret and that the token was fetched successfully; re-run Init after refreshing credentials","Check the region base URL matches the Tuya data center where the device is registered","Confirm the device ID is correct and the device supports WebRTC in the Tuya IoT platform","Log the raw response body to see the full Tuya error code/message for the exact cause"],"exampleFix":"// before\ncfg, err := client.Init()\nif err != nil { log.Fatal(err) }\n// after\ncfg, err := client.Init()\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid token\") || strings.Contains(err.Error(), \"sign\") {\n        log.Fatalf(\"Tuya credential/region problem, check accessId/secret/region: %v\", err)\n    }\n    log.Fatalf(\"init failed: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// before Init: verify config fields are non-empty\nif accessID == \"\" || accessSecret == \"\" || regionURL == \"\" { return errors.New(\"missing tuya cloud config\") }","typeGuard":null,"tryCatchPattern":"cfg, err := client.Init()\nif err != nil {\n    // Tuya API rejections are surfaced verbatim; log and abort or refresh creds\n    log.Printf(\"webrtc config load failed: %v\", err)\n    return err\n}","preventionTips":["Keep accessId/accessSecret in secret management, not hardcoded","Match region URL to the Tuya data center of the device","Confirm device WebRTC support before streaming attempts"],"tags":["go","tuya","cloud-api","webrtc","api-error-response"],"backgroundTag":"api-error-response","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}