{"record":{"id":"e0c9fba24b3ec0e5","repo":"cloudflare/cloudflared","slug":"failed-to-get-command-version-v","errorCode":null,"errorMessage":"Failed to get command version: %v","messagePattern":"Failed to get command version: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"socks/request.go","lineNumber":79,"sourceCode":"\n// Request is a SOCKS5 command with supporting field of the connection\ntype Request struct {\n\t// Protocol version\n\tVersion uint8\n\t// Requested command\n\tCommand uint8\n\t// AddrSpec of the destination\n\tDestAddr *AddrSpec\n\t// reading from the connection\n\tbufConn io.Reader\n}\n\n// NewRequest creates a new request from the connection data stream\nfunc NewRequest(bufConn io.Reader) (*Request, error) {\n\t// Read the version byte\n\theader := []byte{0, 0, 0}\n\tif _, err := io.ReadAtLeast(bufConn, header, 3); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get command version: %v\", err)\n\t}\n\n\t// ensure compatibility\n\tif header[0] != socks5Version {\n\t\treturn nil, fmt.Errorf(\"Unsupported command version: %v\", header[0])\n\t}\n\n\t// Read in the destination address\n\tdest, err := readAddrSpec(bufConn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tVersion:  socks5Version,\n\t\tCommand:  header[1],\n\t\tDestAddr: dest,\n\t\tbufConn:  bufConn,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/socks/request.go#L61-L97","documentation":"NewRequest reads the 3-byte SOCKS request header (version, cmd, rsv) with io.ReadAtLeast; if the read fails, the error is wrapped as 'Failed to get command version'. It precedes the version compatibility check, so it specifically means the header bytes could not be read at all, not that the version was wrong.","triggerScenarios":"Client disconnects after auth but before sending the request header, or sends fewer than 3 bytes, while Serve/createRequest call NewRequest.","commonSituations":"Client crashes or times out mid-session; flaky network closing the stream; aggressive idle timeouts on either side; port scanners that complete auth probes then drop.","solutions":["Retry the client request; the failure is usually a transient connection drop.","Check client-side timeout settings so the client sends the request promptly after auth.","Verify the client fully implements the SOCKS5 request phase after successful auth.","Treat as a normal disconnect in server logs rather than a protocol bug."],"exampleFix":"// before\nreq, err := socks.NewRequest(bufConn)\nif err != nil { return err }\n// after\nreq, err := socks.NewRequest(bufConn)\nif err != nil {\n    if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {\n        return nil // client went away; not a server error\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"req, err := socks.NewRequest(bufConn)\nif err != nil {\n    if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {\n        return nil // client disconnected mid-request\n    }\n    return err\n}","preventionTips":["Set generous client-side request timeouts","Ensure clients send the request promptly after auth","Treat EOF as normal disconnect, not server fault","Monitor frequency; spikes indicate client/network issues"],"tags":["socks5","request","network"],"backgroundTag":"broken-pipe","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"}