XX-net/XX-Net · error

do_sock to %s:%d, x_tunnel fail:%r

Error message

do_sock to %s:%d, x_tunnel fail:%r

What it means

Creating a connection through the x_tunnel proxy session raised an exception; do_socks logs host/port and re-raises XTunnelNotRunning so the router can fall back to another rule.

Source

Thrown at code/default/smart_router/local/smart_route.py:248

        raise RedirectHttpsFail()

    xlog.debug("host:%s:%d redirect_https connect %s success", host, port, remote_sock.ip)

    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(

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Verify x_tunnel is logged in and its control session is alive before routing traffic to it
  2. Check x-tunnel server address/credentials and connectivity
  3. Let try_loop fall back to the next rule (built-in behavior) and fix the underlying x-tunnel session
  4. Restart or re-login the x-tunnel client if the session is stale
Defensive patterns

Strategy: fallback

Validate before calling

if not g.x_tunnel or not g.x_tunnel.proxy_session.ready(): use_next_rule()

Type guard

def x_tunnel_ready(): return bool(g.x_tunnel and g.x_tunnel.proxy_session)

Try / catch

Catch XTunnelNotRunning and advance to the next routing rule.

Prevention

When it happens

Trigger: Calling g.x_tunnel.proxy_session.create_conn(sock, host, port, True) when the x-tunnel session is broken, not yet established, or its transport threw (e.g. closed control channel, TLS failure).

Common situations: x-tunnel server unreachable, login/session expired, x_tunnel not fully initialized before routing, transient network outage.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/d575b0390e9c4bd4. Report an issue: GitHub.