{"record":{"id":"95600bd5a3c4dfcc","repo":"AlexxIT/go2rtc","slug":"discovery-timeout","errorCode":null,"errorMessage":"discovery timeout","messagePattern":"discovery timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tutk/dtls/conn_dtls.go","lineNumber":541,"sourceCode":"\t\t\tif binary.LittleEndian.Uint16(buf[4:]) == cmdDiscoCC51 {\n\t\t\t\tc.addr, c.isCC51, c.ticket = addr, true, binary.LittleEndian.Uint16(buf[14:])\n\t\t\t\tif n >= 24 {\n\t\t\t\t\tcopy(c.sid, buf[16:24])\n\t\t\t\t}\n\t\t\t\treturn c.discoDoneCC51()\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// IOTC Protocol (Basis)\n\t\tdata := tutk.ReverseTransCodeBlob(buf[:n])\n\t\tif len(data) >= 16 && binary.LittleEndian.Uint16(data[8:]) == cmdDiscoRes {\n\t\t\tc.addr, c.isCC51 = addr, false\n\t\t\treturn c.discoDone()\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"discovery timeout\")\n}\n\nfunc (c *DTLSConn) discoDone() error {\n\tc.Write(c.msgDisco(2))\n\ttime.Sleep(100 * time.Millisecond)\n\t_, err := c.WriteAndWait(c.msgSession(), func(res []byte) bool {\n\t\treturn len(res) >= 16 && binary.LittleEndian.Uint16(res[8:]) == cmdSessionRes\n\t})\n\treturn err\n}\n\nfunc (c *DTLSConn) discoDoneCC51() error {\n\t_, err := c.WriteAndWait(c.msgDiscoCC51(2, c.ticket, false), func(res []byte) bool {\n\t\tif len(res) < packetSizeCC51 || string(res[:2]) != magicCC51 {\n\t\t\treturn false\n\t\t}\n\t\tcmd := binary.LittleEndian.Uint16(res[4:])\n\t\tdir := binary.LittleEndian.Uint16(res[8:])","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tutk/dtls/conn_dtls.go#L523-L559","documentation":"discovery waits for the camera's discovery response (cmdDiscoRes) on the LAN/broadcast channel; if it never arrives, DialDTLS fails with this error. It means the host could not discover the camera before giving up, so no session address was learned.","triggerScenarios":"DialDTLS -> discovery when no UDP packet with cmdDiscoRes at offset 8 is received within the discovery window — camera offline, wrong network/broadcast, or discovery response dropped.","commonSituations":"Camera on a different subnet/VLAN than the host; camera asleep or just powered on; mDNS/UDP broadcast blocked by AP isolation; wrong device UID leading to no responder.","solutions":["Verify the device UID/identifier is correct","Ensure host and camera are on the same L2 network or that UDP discovery relays are available","Power-cycle the camera and retry DialDTLS","Check for client/AP isolation or firewall rules blocking the discovery packets"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// precondition checks before DialDTLS\nif deviceUID == \"\" || !sameSubnet(hostIP, camSubnet) {\n\treturn fmt.Errorf(\"discovery cannot reach camera network\")\n}","typeGuard":null,"tryCatchPattern":"conn, err := dtls.DialDTLS(ctx, uid, psk)\nif err != nil {\n\tif strings.Contains(err.Error(), \"discovery timeout\") {\n\t\t// power-cycle/ping camera, then retry once\n\t}\n\treturn err\n}","preventionTips":["Verify the UID and that host and camera share the L2 network","Disable AP/client isolation on the wireless network","Retry discovery after power-cycling the camera","Warn users when camera is offline before dialing"],"tags":["discovery","udp","network","timeout"],"backgroundTag":"request-timeout","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"}