{"record":{"id":"eca67e228f14467b","repo":"AlexxIT/go2rtc","slug":"mqttconfigresponse-msg","errorCode":null,"errorMessage":"${mqttConfigResponse.Msg}","messagePattern":"\\$\\{mqttConfigResponse\\.Msg\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/smart_api.go","lineNumber":549,"sourceCode":"\t}, nil\n}\n\nfunc (c *TuyaSmartApiClient) loadHubConfig() (config *MQTTConfig, err error) {\n\tmqttUrl := fmt.Sprintf(\"https://%s/api/jarvis/mqtt\", c.baseUrl)\n\n\tmqttBody, err := c.request(\"POST\", mqttUrl, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar mqttConfigResponse MQTTConfigResponse\n\terr = json.Unmarshal(mqttBody, &mqttConfigResponse)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !mqttConfigResponse.Success {\n\t\treturn nil, errors.New(mqttConfigResponse.Msg)\n\t}\n\n\treturn &MQTTConfig{\n\t\tUrl:            c.mqttsUrl,\n\t\tClientID:       fmt.Sprintf(\"web_%s\", mqttConfigResponse.Result.Msid),\n\t\tUsername:       fmt.Sprintf(\"web_%s\", mqttConfigResponse.Result.Msid),\n\t\tPassword:       mqttConfigResponse.Result.Password,\n\t\tPublishTopic:   \"/av/moto/moto_id/u/{device_id}\",\n\t\tSubscribeTopic: fmt.Sprintf(\"/av/u/%s\", mqttConfigResponse.Result.Msid),\n\t}, nil\n}\n\nfunc (c *TuyaSmartApiClient) 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":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/smart_api.go#L531-L567","documentation":"GetMQTTConfig returns this error when the Tuya MQTT-config API responds with Success=false; mqttConfigResponse.Msg is passed directly to errors.New. Without this config the client cannot connect to Tuya's MQTT broker, so live event streaming fails. The server's message is propagated unchanged.","triggerScenarios":"Calling GetMQTTConfig when the mqtt-config endpoint returns Success=false — expired login/session, invalid Msid request, or cloud rejection.","commonSituations":"Session expired more than 2 days after login (expireTime lapsed); wrong region endpoint; Tuya cloud outage; calling before successful PasswordLogin.","solutions":["Read Msg to identify auth vs. server failure; re-login if authentication-related.","Ensure PasswordLogin succeeded and is recent before requesting MQTT config.","Verify region/endpoint configuration.","Retry with backoff for transient errors.","Log the raw response body on failure for Tuya support tickets."],"exampleFix":"// before\ncfg, err := client.GetMQTTConfig()\nif err != nil {\n    return err\n}\n// after\ncfg, err := client.GetMQTTConfig()\nif err != nil {\n    return fmt.Errorf(\"mqtt config: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if time.Now().Unix() >= client.expireTime { re-login before GetMQTTConfig() }","typeGuard":null,"tryCatchPattern":"cfg, err := client.GetMQTTConfig()\nif err != nil {\n    if err := client.relogin(); err != nil { return err }\n    cfg, err = client.GetMQTTConfig()\n    if err != nil { return fmt.Errorf(\"mqtt config after relogin: %w\", err) }\n}","preventionTips":["Track expireTime and re-login before it lapses (2-day window)","Only call after successful PasswordLogin","Verify region endpoint","Backoff-retry transient cloud errors"],"tags":["api","tuya","mqtt"],"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-16T04:17:20.429Z"}