AlexxIT/go2rtc · error

tuya: no mqtt client

Error message

tuya: no mqtt client

What it means

Tuya Dial guard: after setting up the WebRTC connection, api.GetMqtt() returned nil — the API layer has no live MQTT client (login/connect failed earlier or was never completed). Without MQTT there is no signaling channel, so the client is closed and Dial aborts.

Solutions

  1. Check earlier login/API errors that left MQTT uninitialized
  2. Verify Tuya credentials and internet reachability, then retry Dial
  3. Ensure the API client's Connect/MQTT setup completes before streaming
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pkg/tuya/client.go:139 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/tuya/client.go:139

		client.Close(err)
		return nil, err
	}

	// protect from sending ICE candidate before Offer
	var sendOffer core.Waiter

	// protect from blocking on errors
	defer sendOffer.Done(nil)

	// Create new WebRTC connection
	client.conn = webrtc.NewConn(client.pc)
	client.conn.FormatName = "tuya/webrtc"
	client.conn.Mode = core.ModeActiveProducer
	client.conn.Protocol = "mqtt"

	mqttClient := client.api.GetMqtt()
	if mqttClient == nil {
		err = errors.New("tuya: no mqtt client")
		client.Close(err)
		return nil, err
	}

	// Set up MQTT handlers
	mqttClient.handleAnswer = func(answer AnswerFrame) {
		// fmt.Printf("tuya: answer: %s\n", answer.Sdp)

		desc := pion.SessionDescription{
			Type: pion.SDPTypePranswer,
			SDP:  answer.Sdp,
		}

		if err = client.pc.SetRemoteDescription(desc); err != nil {
			client.Close(err)
			return
		}

View on GitHub (pinned to c245815e75)