{"record":{"id":"1d579ca9a7b78762","repo":"AlexxIT/go2rtc","slug":"openiothubconfigresponse-msg","errorCode":null,"errorMessage":"openIoTHubConfigResponse.Msg","messagePattern":"openIoTHubConfigResponse\\.Msg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/cloud_api.go","lineNumber":257,"sourceCode":"\t\tUID:      c.uid,\n\t\tUniqueID: uuid.New().String(),\n\t\tLinkType: \"mqtt\",\n\t\tTopics:   \"ipc\",\n\t}\n\n\tbody, err := c.request(\"POST\", url, request)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar openIoTHubConfigResponse OpenIoTHubConfigResponse\n\terr = json.Unmarshal(body, &openIoTHubConfigResponse)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !openIoTHubConfigResponse.Success {\n\t\treturn nil, fmt.Errorf(openIoTHubConfigResponse.Msg)\n\t}\n\n\treturn &MQTTConfig{\n\t\tUrl:            openIoTHubConfigResponse.Result.Url,\n\t\tUsername:       openIoTHubConfigResponse.Result.Username,\n\t\tPassword:       openIoTHubConfigResponse.Result.Password,\n\t\tClientID:       openIoTHubConfigResponse.Result.ClientID,\n\t\tPublishTopic:   openIoTHubConfigResponse.Result.SinkTopic.IPC,\n\t\tSubscribeTopic: openIoTHubConfigResponse.Result.SourceSink.IPC,\n\t}, nil\n}\n\nfunc (c *TuyaCloudApiClient) request(method string, url string, body any) ([]byte, error) {\n\tvar bodyReader io.Reader\n\tif body != nil {\n\t\tjsonBody, err := json.Marshal(body)\n\t\tif err != nil {\n\t\t\treturn nil, err","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/cloud_api.go#L239-L275","documentation":"This error is returned by loadHubConfig when the Tuya OpenIoT hub config endpoint answers with Success=false; the server's Msg field is wrapped in a Go error. It means the MQTT connection parameters (Url/Username/Password) could not be obtained because the cloud rejected the request. Transport succeeded — the API call itself failed.","triggerScenarios":"Init() -> loadHubConfig() requests the openIoT hub/MQTT config and the JSON response contains Success=false. Causes: invalid or expired cloud token, wrong region base URL, bad signing, or account/device not provisioned for MQTT hub access.","commonSituations":"Seen when Tuya credentials were rotated, when the token endpoint and config endpoint use mismatched regions, or when the device was removed from the Tuya account so the cloud refuses to issue MQTT credentials.","solutions":["Re-run the token init flow and ensure the access token is fresh before requesting hub config","Confirm the region/base URL is correct for your Tuya account data center","Verify the device still exists in your Tuya IoT account and is linked to the app/namespace","Inspect the Tuya response (Msg/code) for the specific rejection reason and fix credentials accordingly"],"exampleFix":"// before\nmqttCfg, err := client.Init()\nif err != nil { panic(err) }\n// after\nmqttCfg, err := client.Init()\nif err != nil {\n    if strings.Contains(err.Error(), \"token\") {\n        // refresh token / re-authenticate before retrying\n        if rerr := client.Init(); rerr != nil { panic(rerr) }\n        return\n    }\n    panic(err)\n}","handlingStrategy":"try-catch","validationCode":"if deviceID == \"\" || accessSecret == \"\" { return errors.New(\"missing tuya hub config\") }","typeGuard":null,"tryCatchPattern":"mqttCfg, err := client.Init()\nif err != nil {\n    if strings.Contains(err.Error(), \"token\") { refreshCredentials(); return retry() }\n    return err\n}","preventionTips":["Refresh the access token before requesting hub config","Re-check device linkage in the Tuya IoT console after account changes","Log raw cloud responses during integration to catch Success=false early"],"tags":["go","tuya","cloud-api","mqtt","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"}