{"record":{"id":"719c887c0f4edc5f","repo":"AlexxIT/go2rtc","slug":"can-t-open-two-udp-ports","errorCode":null,"errorMessage":"can't open two UDP ports","messagePattern":"can't open two UDP ports","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rtsp/client.go","lineNumber":455,"sourceCode":"\t\t\tport2 = port1 - 1\n\t\t} else {\n\t\t\tport2 = port1 + 1\n\t\t}\n\n\t\tln2, err := net.ListenUDP(\"udp\", &net.UDPAddr{IP: nil, Port: port2})\n\t\tif err != nil {\n\t\t\t_ = ln1.Close()\n\t\t\tcontinue\n\t\t}\n\n\t\tif port1 < port2 {\n\t\t\treturn ln1, ln2, nil\n\t\t} else {\n\t\t\treturn ln2, ln1, nil\n\t\t}\n\t}\n\n\treturn nil, nil, fmt.Errorf(\"can't open two UDP ports\")\n}\n","sourceCodeStart":437,"sourceCodeEnd":457,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/rtsp/client.go#L437-L457","documentation":"ListenUDPPair exhausted its retry loop trying to bind two adjacent UDP ports (port and port±1) for RTP/RTCP; at least one bind always failed. Typically caused by firewall restrictions or port exhaustion; no listener pair is returned.","triggerScenarios":"Thrown at pkg/rtsp/client.go:455 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Free the occupied UDP port range","Use TCP interleaved transport instead of UDP"],"exampleFix":null,"handlingStrategy":"fallback","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"}