{"record":{"id":"56c20ef668ba28b3","repo":"cloudflare/cloudflared","slug":"internal-error-unsupported-connection-type","errorCode":null,"errorMessage":"internal error: unsupported connection type","messagePattern":"internal error: unsupported connection type","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/proxy.go","lineNumber":249,"sourceCode":"\n\theaders := make(http.Header, len(resp.Header))\n\t// copy headers\n\tfor k, v := range resp.Header {\n\t\theaders[k] = v\n\t}\n\n\t// Add spans to response header (if available)\n\ttr.AddSpans(headers)\n\n\terr = w.WriteRespHeaders(resp.StatusCode, headers)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error writing response header\")\n\t}\n\n\tif resp.StatusCode == http.StatusSwitchingProtocols {\n\t\trwc, ok := resp.Body.(io.ReadWriteCloser)\n\t\tif !ok {\n\t\t\treturn errors.New(\"internal error: unsupported connection type\")\n\t\t}\n\t\tdefer func() { _ = rwc.Close() }()\n\n\t\teyeballStream := &bidirectionalStream{\n\t\t\twriter: w,\n\t\t\treader: tr.Body,\n\t\t}\n\n\t\tstream.Pipe(eyeballStream, rwc, logger)\n\t\treturn nil\n\t}\n\n\tif _, err = cfio.Copy(w, resp.Body); err != nil {\n\t\treturn err\n\t}\n\n\t// copy trailers\n\tcopyTrailers(w, resp)","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/proxy/proxy.go#L231-L267","documentation":"proxyHTTPRequest returns this when the origin responds with HTTP 101 Switching Protocols but the response body does not implement io.ReadWriteCloser, so cloudflared cannot splice a bidirectional stream. This is an internal invariant violation, not a user-configurable condition.","triggerScenarios":"resp.StatusCode == http.StatusSwitchingProtocols and the type assertion resp.Body.(io.ReadWriteCloser) fails in proxy/proxy.go, called from ProxyHTTP.","commonSituations":"Websocket or other protocol-upgrade requests proxied through a transport whose response body type does not support raw read/write access (e.g. unexpected transport change or Go version behavior).","solutions":["Report this as a bug to cloudflared — it signals an unsupported internal transport type","Verify your cloudflared version is current; upgrade to pick up transport fixes","Work around by disabling the protocol upgrade on the origin (e.g. plain HTTP instead of websockets) to confirm the trigger"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := proxy.ProxyHTTP(w, r, isWebsocket)\nif err != nil && strings.Contains(err.Error(), \"unsupported connection type\") {\n    // report/upgrade; degrade gracefully e.g. reject the upgrade request\n    http.Error(w, \"protocol upgrade unsupported\", http.StatusBadGateway)\n}","preventionTips":["Keep cloudflared up to date so transports always expose ReadWriteCloser bodies","Test websocket origins through the proxy before production rollout"],"tags":["proxy","websocket","internal","http"],"backgroundTag":"internal-invariant-violation","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}