{"record":{"id":"ef4cb5d054b2e80c","repo":"AlexxIT/go2rtc","slug":"eseecloud-wrong-start-byte","errorCode":null,"errorMessage":"eseecloud: wrong start byte","messagePattern":"eseecloud: wrong start byte","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/eseecloud/eseecloud.go","lineNumber":163,"sourceCode":"\t\t\t\t\t\tTimestamp:      uint32(uint64(pkt.Timestamp) * 8000 / 1000000),\n\t\t\t\t\t},\n\t\t\t\t\tPayload: pkt.Payload,\n\t\t\t\t}\n\t\t\t}\n\t\t\trecv.WriteRTP(pkt)\n\t\t}\n\t}\n}\n\nfunc (p *Producer) readPacket() (*core.Packet, error) {\n\tb := make([]byte, 8)\n\n\tif _, err := io.ReadFull(p.rd, b); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif b[0] != '$' {\n\t\treturn nil, errors.New(\"eseecloud: wrong start byte\")\n\t}\n\n\tsize := binary.BigEndian.Uint32(b[4:])\n\tb = make([]byte, size)\n\tif _, err := io.ReadFull(p.rd, b); err != nil {\n\t\treturn nil, err\n\t}\n\n\tpkt := &core.Packet{}\n\tif err := pkt.Unmarshal(b); err != nil {\n\t\treturn nil, err\n\t}\n\n\tp.Recv += int(size)\n\n\treturn pkt, nil\n}\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/eseecloud/eseecloud.go#L145-L181","documentation":"eseecloud.readPacket (pkg/eseecloud/eseecloud.go:163) reads a packet header via io.ReadFull and requires the first byte to be '$'. If b[0] != '$' it returns \"eseecloud: wrong start byte\", meaning the TCP stream is no longer aligned with the EseeCloud packet framing or the peer is not speaking the EseeCloud protocol.","triggerScenarios":"readPacket, invoked by Start and probe, when the first byte of a packet is not '$' — desynced stream after a partial read, garbage injected mid-session, or a non-EseeCloud service on the port.","commonSituations":"Device or cloud relay resetting the connection and sending an error page/HTML instead of framed packets; wrong host/port (connecting to camera HTTP UI instead of the EseeCloud stream port); leftover partial packet from a previous error desynchronizing the reader.","solutions":["Reconnect (restart Start/probe): once the stream is misaligned, the framing cannot recover in place.","Verify the host and port actually serve the EseeCloud protocol (captured packets should start with '$').","Rule out middleboxes or relays replacing the payload (HTML error pages, captive portals).","Check device firmware compatibility; a protocol change can alter the framing.","Capture traffic to inspect the exact bytes arriving when the error occurs."],"exampleFix":"// before: keep reading after desync\nfor {\n    pkt, err := p.readPacket() // wrong start byte repeats\n}\n// after: rebuild the connection\nif err != nil {\n    p.Close()\n    err = p.Start(ctx) // fresh TCP session, resynced framing\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"pkt, err := p.readPacket()\nif err != nil && strings.HasSuffix(err.Error(), \"wrong start byte\") {\n    p.Close()\n    err = p.Start(ctx) // resync requires a new session\n}","preventionTips":["Restart the session on any framing error","Confirm the port serves EseeCloud ('$'-framed packets)","Avoid relays/proxies that can inject data","Watch for device-side resets and reconnect quickly"],"tags":["network","protocol","stream","camera"],"backgroundTag":"unexpected-api-response-shape","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"}