{"record":{"id":"d595dafeac844781","repo":"AlexxIT/go2rtc","slug":"failed-to-send-codec-request-w","errorCode":null,"errorMessage":"failed to send codec request: %w","messagePattern":"failed to send codec request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/client.go","lineNumber":262,"sourceCode":"\t\t\t// fmt.Printf(\"tuya: datachannel error: %s\\n\", err.Error())\n\t\t\tclient.Close(err)\n\t\t})\n\n\t\tclient.dc.OnClose(func() {\n\t\t\t// fmt.Println(\"tuya: datachannel closed\")\n\t\t\tclient.Close(errors.New(\"datachannel: closed\"))\n\t\t})\n\n\t\tclient.dc.OnOpen(func() {\n\t\t\t// fmt.Println(\"tuya: datachannel opened\")\n\n\t\t\tcodecRequest, _ := json.Marshal(DataChannelMessage{\n\t\t\t\tType: \"codec\",\n\t\t\t\tMsg:  \"\",\n\t\t\t})\n\n\t\t\tif err := client.sendMessageToDataChannel(codecRequest); err != nil {\n\t\t\t\tclient.Close(fmt.Errorf(\"failed to send codec request: %w\", err))\n\t\t\t}\n\t\t})\n\t}\n\n\t// Set up pc handler\n\tclient.conn.Listen(func(msg any) {\n\t\tswitch msg := msg.(type) {\n\t\tcase *pion.ICECandidate:\n\t\t\t_ = sendOffer.Wait()\n\t\t\tif err := mqttClient.SendCandidate(\"a=\" + msg.ToJSON().Candidate); err != nil {\n\t\t\t\tclient.Close(err)\n\t\t\t}\n\n\t\tcase pion.PeerConnectionState:\n\t\t\tswitch msg {\n\t\t\tcase pion.PeerConnectionStateNew:\n\t\t\t\tbreak\n\t\t\tcase pion.PeerConnectionStateConnecting:","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/client.go#L244-L280","documentation":"On WebRTC datachannel open, the JSON 'codec' request could not be sent to Tuya's datachannel (sendMessageToDataChannel failed), so the client is closed with this wrapped error — codec negotiation cannot begin. Wraps the send error.","triggerScenarios":"Thrown at pkg/tuya/client.go:262 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the connection; transient data channel setup races can cause this","Verify WebRTC/DTLS connectivity to the Tuya cloud"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}