{"record":{"id":"71d50c6008a49cca","repo":"XX-net/XX-Net","slug":"x-tunnel-create-conn-fail","errorCode":null,"errorMessage":"x_tunnel create conn fail","messagePattern":"x_tunnel create conn fail","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"code/default/smart_router/local/smart_route.py","lineNumber":252,"sourceCode":"    if left_buf:\n        ssl_sock.send(left_buf)\n    sw = SocketWrap(ssl_sock, remote_sock.ip, port, host)\n    sock.recved_times = 3\n    g.pipe_socks.add_socks(sock, sw)\n\n\ndef do_socks(sock, host, port, client_address, left_buf=b\"\"):\n    if not g.x_tunnel:\n        raise XTunnelNotRunning()\n\n    try:\n        conn_id = g.x_tunnel.proxy_session.create_conn(sock, host, port, True)\n    except Exception as e:\n        xlog.warn(\"do_sock to %s:%d, x_tunnel fail:%r\", host, port, e)\n        raise XTunnelNotRunning()\n\n    if not conn_id:\n        xlog.warn(\"x_tunnel create conn fail\")\n        raise XTunnelNotRunning()\n\n    # xlog.debug(\"do_socks %r connect to %s:%d conn_id:%d\", client_address, host, port, conn_id)\n    if left_buf:\n        g.x_tunnel.global_var.session.conn_list[conn_id].transfer_received_data(left_buf)\n    g.x_tunnel.global_var.session.conn_list[conn_id].start(block=True)\n\n\ndef do_unwrap_socks(sock, host, port, client_address, req, left_buf=b\"\"):\n    if not g.x_tunnel:\n        return\n\n    try:\n        remote_sock = socks.create_connection(\n            (host, port),\n            proxy_type=\"socks5h\", proxy_addr=\"127.0.0.1\", proxy_port=g.x_tunnel_socks_port, timeout=15\n        )\n    except Exception as e:","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/smart_route.py#L234-L270","documentation":"create_conn returned a falsy conn_id (0/None), meaning x-tunnel could not allocate a connection. XTunnelNotRunning is raised so routing falls back.","triggerScenarios":"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.","commonSituations":"Too many concurrent x-tunnel connections, half-dead session after network change, server-side resource limits.","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)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if active_conns() >= MAX_CONNS: use_next_rule()","typeGuard":null,"tryCatchPattern":"Treat falsy conn_id as transport failure; fall back to next rule.","preventionTips":["Bound concurrent x-tunnel connections","Re-login x-tunnel on stale sessions"],"tags":["x-tunnel","connection","resource-exhaustion"],"backgroundTag":"proxy-session-unavailable","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}