XX-net/XX-Net · warning
request version:%d error
Error message
request version:%d error
What it means
Logged by X-Tunnel's socks5_handler when the request frame's version byte is not 5 (e.g. 4 for SOCKS4). The handler refuses the request and closes the connection. Note the preceding debug line referencing auth_mode_num/data is leftover from the greeting stage and will itself often fail with NameError on that path in strict review — the effective signal is the non-5 version.
Source
Thrown at code/default/x_tunnel/local/proxy_handler.py:239
g.session.conn_list[conn_id].start(block=True)
def socks5_handler(self):
sock = self.connection
auth_mode_num = ord(self.read_bytes(1))
data = self.read_bytes(auth_mode_num)
sock.send(b"\x05\x00") # socks version 5, no auth needed.
try:
data = self.read_bytes(4)
except Exception as e:
xlog.debug("socks5 auth num:%d, list:%s", auth_mode_num, utils.str2hex(data))
xlog.warn("socks5 protocol error:%r", e)
return
socks_version = ord(data[0:1])
if socks_version != 5:
xlog.warn("request version:%d error", socks_version)
return
command = ord(data[1:2])
if command != 1: # 1. Tcp connect
xlog.warn("request not supported command mode:%d", command)
sock.send(b"\x05\x07\x00\x01") # Command not supported
return
addrtype_pack = data[3:4]
addrtype = ord(addrtype_pack)
if addrtype == 1: # IPv4
addr_pack = self.read_bytes(4)
addr = socket.inet_ntoa(addr_pack)
elif addrtype == 3: # Domain name
domain_len_pack = self.read_bytes(1)[0:1]
domain_len = ord(domain_len_pack)
domain = self.read_bytes(domain_len)
addr_pack = domain_len_pack + domainView on GitHub (pinned to cfa5bc17b6)
Solutions
- Set the client to SOCKS5: socks5://127.0.0.1:<port>
- Confirm the application is connecting to the X-Tunnel local port, not another service
- Remove the stale debug line referencing undefined auth_mode_num/data in the except block to avoid masking the real error
Example fix
# before
except Exception as e:
xlog.debug("socks5 auth num:%d, list:%s", auth_mode_num, utils.str2hex(data))
xlog.warn("socks5 protocol error:%r", e)
# after
except Exception as e:
xlog.warn("socks5 protocol error:%r", e) Defensive patterns
Strategy: validation
Validate before calling
# client side assert proxy_scheme == 'socks5', 'X-Tunnel local proxy is SOCKS5 only'
Prevention
- Use socks5:// in client configuration
- Remove the stale debug line in the except block so real errors surface
When it happens
Trigger: A SOCKS4 client or a non-SOCKS protocol sends bytes to the X-Tunnel local SOCKS5 port after the initial greeting exchange.
Common situations: Client proxy configured as SOCKS4 instead of SOCKS5, wrong port targeted by another application, protocol garbage from port scans.
Related errors
- request version:%d error
- socks5 protocol error:%r
- entity header:%s
- helper failed:%r, please manually reset proxy settings after
- set LAN Proxy to %s:%d fail.
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/c9f24b0c71d7e476.
Report an issue: GitHub.