XX-net/XX-Net · warning
socks5 %r connect to %s:%d conn_id:%d closed:%r
Error message
socks5 %r connect to %s:%d conn_id:%d closed:%r
What it means
After a successful SOCKS5 CONNECT and create_conn, sending the success reply to the client raised (client vanished/reset). The tunnel conn is stopped via do_stop and the warning logged with the exception.
Source
Thrown at code/default/x_tunnel/local/proxy_handler.py:283
return
port = struct.unpack('>H', self.rfile.read(2))[0]
conn_id = proxy_session.create_conn(sock, addr, port)
if not conn_id:
xlog.warn("socks5 create conn to %s:%d fail", addr, port)
reply = b"\x05\x01\x00" + addrtype_pack + addr_pack + struct.pack(">H", port)
sock.send(reply)
return
xlog.info("socks5 %r connect to %s:%d conn:%d", self.client_address, addr, port, conn_id)
reply = b"\x05\x00\x00" + addrtype_pack + addr_pack + struct.pack(">H", port)
try:
sock.send(reply)
except Exception as e:
if conn_id in g.session.conn_list:
g.session.conn_list[conn_id].do_stop("close_on_Socks5_reply")
xlog.warn("socks5 %r connect to %s:%d conn_id:%d closed:%r", self.client_address, addr, port, conn_id, e)
return
if len(self.read_buffer) - self.buffer_start:
g.session.conn_list[conn_id].transfer_received_data(self.read_buffer[self.buffer_start:])
g.session.conn_list[conn_id].start(block=True)
def https_handler(self):
line = self.read_crlf_line()
line = line.decode('iso-8859-1')
words = line.split()
if len(words) == 3:
command, path, version = words
elif len(words) == 2:
command, path = words
version = b"HTTP/1.1"
else:
xlog.warn("https req line fail:%s", line)View on GitHub (pinned to cfa5bc17b6)
Solutions
- Usually benign — the tunnel is cleaned up automatically
- Increase client connect timeout if frequent
- Check client-side network stability
Defensive patterns
Strategy: try-catch
Try / catch
try:
sock.send(reply)
except Exception as e:
g.session.conn_list[conn_id].do_stop('client_gone') Prevention
- Raise client connect timeouts slightly
When it happens
Trigger: Client disconnects or RSTs between CONNECT request and reply; e.g. timeout or cancel in the client app.
Common situations: Apps with short connect timeouts, page navigations cancelling requests, mobile network switches.
Related errors
- do_unwrap_socks connect to x-tunnel for %s:%d proxy fail.
- request not supported command mode:%d
- request address type unknown:%d
- socks5 create conn to %s:%d fail
- https %r connect to %s:%d conn:%d closed.
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/3f871ac37e3752d5.
Report an issue: GitHub.