{"record":{"id":"57a8df4b614d9a11","repo":"AlexxIT/go2rtc","slug":"wrong-websocket-accept","errorCode":null,"errorMessage":"wrong websocket accept","messagePattern":"wrong websocket accept","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tcp/websocket/dial.go","lineNumber":48,"sourceCode":"\n\t// Version, Key, Protocol important for Axis cameras\n\treq.Header.Set(\"Connection\", \"Upgrade\")\n\treq.Header.Set(\"Upgrade\", \"websocket\")\n\treq.Header.Set(\"Sec-WebSocket-Version\", \"13\")\n\treq.Header.Set(\"Sec-WebSocket-Key\", key)\n\treq.Header.Set(\"Sec-WebSocket-Protocol\", \"binary\")\n\n\tres, err := tcp.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode != http.StatusSwitchingProtocols {\n\t\treturn nil, errors.New(\"wrong status: \" + res.Status)\n\t}\n\n\tif res.Header.Get(\"Sec-Websocket-Accept\") != accept {\n\t\treturn nil, errors.New(\"wrong websocket accept\")\n\t}\n\n\treturn NewClient(*pconn), nil\n}\n\nfunc GetKeyAccept() (key, accept string) {\n\tb := make([]byte, 16)\n\t_, _ = cryptorand.Read(b)\n\tkey = base64.StdEncoding.EncodeToString(b)\n\n\th := sha1.New()\n\th.Write([]byte(key))\n\th.Write([]byte(\"258EAFA5-E914-47DA-95CA-C5AB0DC85B11\"))\n\taccept = base64.StdEncoding.EncodeToString(h.Sum(nil))\n\n\treturn\n}\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tcp/websocket/dial.go#L30-L66","documentation":"WebSocket Dial accept guard: the server did return 101, but the Sec-Websocket-Accept header does not equal the SHA1/base64 of the sent Sec-WebSocket-Key. The handshake response is invalid per RFC 6455 — a broken intermediary or non-compliant server generated the wrong accept value.","triggerScenarios":"Thrown at pkg/tcp/websocket/dial.go:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify no proxy rewrites or caches the 101 response","Test the endpoint with a standard WebSocket client to confirm server compliance","Update or bypass the non-conformant server/intermediary"],"exampleFix":null,"handlingStrategy":"validation","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"}