XX-net/XX-Net · error
x_tunnel create conn fail
Error message
x_tunnel create conn fail
What it means
create_conn returned a falsy conn_id (0/None), meaning x-tunnel could not allocate a connection. XTunnelNotRunning is raised so routing falls back.
Source
Thrown at code/default/smart_router/local/smart_route.py:252
if left_buf:
ssl_sock.send(left_buf)
sw = SocketWrap(ssl_sock, remote_sock.ip, port, host)
sock.recved_times = 3
g.pipe_socks.add_socks(sock, sw)
def do_socks(sock, host, port, client_address, left_buf=b""):
if not g.x_tunnel:
raise XTunnelNotRunning()
try:
conn_id = g.x_tunnel.proxy_session.create_conn(sock, host, port, True)
except Exception as e:
xlog.warn("do_sock to %s:%d, x_tunnel fail:%r", host, port, e)
raise XTunnelNotRunning()
if not conn_id:
xlog.warn("x_tunnel create conn fail")
raise XTunnelNotRunning()
# xlog.debug("do_socks %r connect to %s:%d conn_id:%d", client_address, host, port, conn_id)
if left_buf:
g.x_tunnel.global_var.session.conn_list[conn_id].transfer_received_data(left_buf)
g.x_tunnel.global_var.session.conn_list[conn_id].start(block=True)
def do_unwrap_socks(sock, host, port, client_address, req, left_buf=b""):
if not g.x_tunnel:
return
try:
remote_sock = socks.create_connection(
(host, port),
proxy_type="socks5h", proxy_addr="127.0.0.1", proxy_port=g.x_tunnel_socks_port, timeout=15
)
except Exception as e:View on GitHub (pinned to cfa5bc17b6)
Solutions
- Reduce concurrent connections through x-tunnel / raise its connection limit
- Re-establish the x-tunnel session (re-login/restart)
- Inspect x-tunnel logs for why conn allocation failed
- Fall back to direct or other proxy rules (automatic)
Defensive patterns
Strategy: fallback
Validate before calling
if active_conns() >= MAX_CONNS: use_next_rule()
Try / catch
Treat falsy conn_id as transport failure; fall back to next rule.
Prevention
- Bound concurrent x-tunnel connections
- Re-login x-tunnel on stale sessions
When it happens
Trigger: x-tunnel session accepts the call but fails to allocate a conn_id: session in a bad state, connection table exhausted, or server rejected the creation.
Common situations: Too many concurrent x-tunnel connections, half-dead session after network change, server-side resource limits.
Related errors
- do_sock to %s:%d, x_tunnel fail:%r
- x-tunnel request_balance fail when create_conn:%s
- XTunnelNotRunning
- ConnectionPipe remove sock e:%r
- proxy handler read error %r
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/71d50c6008a49cca.
Report an issue: GitHub.