AlexxIT/go2rtc · error
openIoTHubConfigResponse.Msg
Error message
openIoTHubConfigResponse.Msg
What it means
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.
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
Example fix
// before
mqttCfg, err := client.Init()
if err != nil { panic(err) }
// after
mqttCfg, err := client.Init()
if err != nil {
if strings.Contains(err.Error(), "token") {
// refresh token / re-authenticate before retrying
if rerr := client.Init(); rerr != nil { panic(rerr) }
return
}
panic(err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if deviceID == "" || accessSecret == "" { return errors.New("missing tuya hub config") } Try / catch
mqttCfg, err := client.Init()
if err != nil {
if strings.Contains(err.Error(), "token") { refreshCredentials(); return retry() }
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- webRTCConfigResponse.Msg
- failed to publish wake-up message
- failed to subscribe to lowPower topic
- mqtt client is closed, send mqtt message fail
- failed to initialize token
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/1d579ca9a7b78762.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/tuya/cloud_api.go:257
UID: c.uid,
UniqueID: uuid.New().String(),
LinkType: "mqtt",
Topics: "ipc",
}
body, err := c.request("POST", url, request)
if err != nil {
return nil, err
}
var openIoTHubConfigResponse OpenIoTHubConfigResponse
err = json.Unmarshal(body, &openIoTHubConfigResponse)
if err != nil {
return nil, err
}
if !openIoTHubConfigResponse.Success {
return nil, fmt.Errorf(openIoTHubConfigResponse.Msg)
}
return &MQTTConfig{
Url: openIoTHubConfigResponse.Result.Url,
Username: openIoTHubConfigResponse.Result.Username,
Password: openIoTHubConfigResponse.Result.Password,
ClientID: openIoTHubConfigResponse.Result.ClientID,
PublishTopic: openIoTHubConfigResponse.Result.SinkTopic.IPC,
SubscribeTopic: openIoTHubConfigResponse.Result.SourceSink.IPC,
}, nil
}
func (c *TuyaCloudApiClient) request(method string, url string, body any) ([]byte, error) {
var bodyReader io.Reader
if body != nil {
jsonBody, err := json.Marshal(body)
if err != nil {
return nil, errView on GitHub (pinned to c245815e75)