{"record":{"id":"cabd9e133e42ff83","repo":"AlexxIT/go2rtc","slug":"write-av-login-response-w","errorCode":null,"errorMessage":"write av login response: %w","messagePattern":"write av login response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tutk/dtls/conn_dtls.go","lineNumber":267,"sourceCode":"\tif c.verbose {\n\t\tfmt.Printf(\"[SERVER] AV Login request len=%d data:\\n%s\", n, hexDump(buf[:n]))\n\t}\n\n\tif n < 24 {\n\t\tgo conn.Close()\n\t\treturn fmt.Errorf(\"av login too short: %d bytes\", n)\n\t}\n\n\tchecksum := binary.LittleEndian.Uint32(buf[20:])\n\tresp := c.msgAVLoginResponse(checksum)\n\n\tif c.verbose {\n\t\tfmt.Printf(\"[SERVER] Sending AV Login response: %d bytes\\n\", len(resp))\n\t}\n\n\tif _, err = conn.Write(resp); err != nil {\n\t\tgo conn.Close()\n\t\treturn fmt.Errorf(\"write av login response: %w\", err)\n\t}\n\n\tif c.verbose {\n\t\tfmt.Printf(\"[SERVER] AV Login response sent, waiting for possible resend...\\n\")\n\t}\n\n\t// Camera may resend, respond again\n\tconn.SetReadDeadline(time.Now().Add(500 * time.Millisecond))\n\tif n, _ = conn.Read(buf); n > 0 {\n\t\tif c.verbose {\n\t\t\tfmt.Printf(\"[SERVER] Received AV Login resend: %d bytes\\n\", n)\n\t\t}\n\t\tconn.Write(resp)\n\t}\n\n\tconn.SetReadDeadline(time.Time{})\n\n\tif c.verbose {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tutk/dtls/conn_dtls.go#L249-L285","documentation":"AVServStart computes the login response from the request checksum and writes it back; a failure of that Write is wrapped with this error and the server connection is closed. It means the host could not deliver the AV login acceptance to the camera.","triggerScenarios":"StartIntercom -> AVServStart when conn.Write(resp) fails after receiving a valid AV login request — DTLS session closed by the camera, deadline exceeded, or transport error.","commonSituations":"Camera dropped the connection right after sending the login request; network interruption during two-way audio setup; DTLS rekey/close happening concurrently.","solutions":["Inspect the wrapped cause to distinguish timeout vs closed connection","Retry the full intercom start sequence (DTLS handshake + login exchange)","Check network stability between host and camera","Ensure no other goroutine is closing the DTLS conn concurrently"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if conn == nil || conn.IsClosed() {\n\treturn fmt.Errorf(\"intercom session closed before response\")\n}","typeGuard":null,"tryCatchPattern":"if err := conn.AVServStart(); err != nil {\n\tif errors.Is(err, net.ErrClosed) {\n\t\t// camera dropped; restart full intercom sequence\n\t}\n\treturn err\n}","preventionTips":["Restart the whole intercom flow after a response-write failure","Avoid concurrent Close calls on the DTLS conn","Check network stability for two-way audio sessions","Use verbose logging to spot camera-side disconnects early"],"tags":["dtls","write","network","intercom"],"backgroundTag":"broken-pipe","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"}