{"record":{"id":"36433396fbb2356c","repo":"XX-net/XX-Net","slug":"request-version-d-error","errorCode":null,"errorMessage":"request version:%d error","messagePattern":"request version:(.+?) error","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/proxy_handler.py","lineNumber":263,"sourceCode":"        xlog.debug(\"socks5 from:%r udp associate to %s:%d closed\", self.client_address, addr, port)\n\n    def socks5_handler(self):\n        sock = self.conn\n        socks_version = ord(self.read_bytes(1))\n        auth_mode_num = ord(self.read_bytes(1))\n        data = self.read_bytes(auth_mode_num)\n\n        sock.send(b\"\\x05\\x00\")  # socks version 5, no auth needed.\n        try:\n            data = self.read_bytes(4)\n        except Exception as e:\n            xlog.debug(\"socks5 auth num:%d, list:%s\", auth_mode_num, utils.str2hex(data))\n            xlog.warn(\"socks5 protocol error:%r\", e)\n            return\n\n        socks_version = ord(data[0:1])\n        if socks_version != 5:\n            xlog.warn(\"request version:%d error\", socks_version)\n            return\n\n        command = ord(data[1:2])\n        addrtype_pack = data[3:4]\n        addrtype = ord(addrtype_pack)\n        if addrtype == 1:  # IPv4\n            addr_pack = self.read_bytes(4)\n            addr = socket.inet_ntoa(addr_pack)\n        elif addrtype == 3:  # Domain name\n            domain_len_pack = self.read_bytes(1)[0:1]\n            domain_len = ord(domain_len_pack)\n            domain = self.read_bytes(domain_len)\n            addr_pack = domain_len_pack + domain\n            addr = domain\n        elif addrtype == 4:  # IPv6\n            addr_pack = self.read_bytes(16)\n            addr = socket.inet_ntop(socket.AF_INET6, addr_pack)\n        else:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/proxy_handler.py#L245-L281","documentation":"Logged (not raised) by socks5_handler in the smart_router proxy: after the SOCKS5 greeting, the client's request frame reports a version byte other than 5. SOCKS5 requires every frame to start with 0x05; anything else (often 0x04 for SOCKS4, or garbage) is rejected and the handler returns, closing the connection.","triggerScenarios":"A client configured for SOCKS4 or speaking a non-SOCKS protocol connects to the local SOCKS5 port; or a malformed request frame arrives after a valid greeting.","commonSituations":"App/browser proxy settings specify socks4:// instead of socks5://, client library bug, port reuse collision where another protocol connects to the proxy port.","solutions":["Configure the client to use SOCKS5 (e.g. socks5://127.0.0.1:<port>) not SOCKS4","Confirm the client is connecting to the intended local proxy port","If frames are truncated, check for MTU/interception issues between client and proxy"],"exampleFix":"# client config\n# before\nsocks4://127.0.0.1:1080\n\n# after\nsocks5://127.0.0.1:1080","handlingStrategy":"validation","validationCode":"# client side: use socks5 scheme\nproxy = 'socks5://127.0.0.1:1080'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure clients with socks5:// not socks4://","Document the correct proxy scheme/port for users of the router"],"tags":["socks5","protocol-mismatch","proxy"],"backgroundTag":"socks-protocol-version-mismatch","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}