AlexxIT/go2rtc · error

read av login

Error message

read av login: %w

What it means

After the DTLS server handshake, AVServStart waits up to 5 seconds for the camera's AV login request and wraps any Read error with this message. It means no AV login packet arrived (or the read failed) within the deadline, and the server connection is closed.

Solutions

  1. Increase or verify the 5-second read deadline is enough for your network
  2. Confirm the camera actually completed the DTLS handshake and is in the login phase (verbose logs)
  3. Check PSK correctness — a wrong PSK causes the camera's login to be rejected/dropped
  4. Retry the whole AVServStart flow; the conn is closed on this path
Defensive patterns

Strategy: retry

Try / catch

if err := conn.AVServStart(); err != nil {
	if strings.Contains(err.Error(), "read av login") || errors.Is(err, os.ErrDeadlineExceeded) {
		// camera never sent login; restart intercom flow
	}
}

Prevention

When it happens

Trigger: StartIntercom -> AVServStart when conn.Read returns an error before receiving the camera's AV login request: read deadline exceeded, DTLS conn closed, or decrypt failure surfacing as a read error.

Common situations: Camera never sends the AV login because its side of the handshake or session setup failed; slow camera/network exceeding the 5s deadline; camera disconnected right after handshake.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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

Appendix: source

Thrown at pkg/tutk/dtls/conn_dtls.go:246

func (c *DTLSConn) AVServStart() error {
	conn, err := NewDTLSServer(c.ctx, iotcChannelBack, c.addr, c.WriteDTLS, c.serverBuf, c.psk)
	if err != nil {
		return fmt.Errorf("dtls: server handshake failed: %w", err)
	}

	if c.verbose {
		fmt.Printf("[DTLS] Server handshake complete on channel %d\n", iotcChannelBack)
		fmt.Printf("[SERVER] Waiting for AV Login request from camera...\n")
	}

	// Wait for AV Login request from camera
	buf := make([]byte, 1024)
	conn.SetReadDeadline(time.Now().Add(5 * time.Second))
	n, err := conn.Read(buf)
	if err != nil {
		go conn.Close()
		return fmt.Errorf("read av login: %w", err)
	}

	if c.verbose {
		fmt.Printf("[SERVER] AV Login request len=%d data:\n%s", n, hexDump(buf[:n]))
	}

	if n < 24 {
		go conn.Close()
		return fmt.Errorf("av login too short: %d bytes", n)
	}

	checksum := binary.LittleEndian.Uint32(buf[20:])
	resp := c.msgAVLoginResponse(checksum)

	if c.verbose {
		fmt.Printf("[SERVER] Sending AV Login response: %d bytes\n", len(resp))
	}

View on GitHub (pinned to c245815e75)