XX-net/XX-Net · error

login_session time:%d fail, res:%d msg:%s

Error message

login_session time:%d fail, res:%d msg:%s

What it means

Logged when the X-Tunnel session server login fails: the server returned a non-zero result code (res != 0) in the login response. The message includes elapsed time, result code, and server message; g.last_api_error is set to 'session server login fail, code:%d msg:%s'. login_session returns False, causing start() to fail.

Source

Thrown at code/default/x_tunnel/local/proxy_session.py:449

                if len(content) < 6:
                    g.last_api_error = "session server protocol fail, login res len:%d" % len(content)
                    xlog.error("login data len:%d fail", len(content))
                    continue

                info = decrypt_data(content)
                magic, protocol_version, pack_type, res, message_len = struct.unpack("<cBBBH", info[:6])
                message = info[6:]
                if isinstance(message, memoryview):
                    message = message.tobytes()

                if magic != b"P" or protocol_version != g.protocol_version or pack_type != 1:
                    xlog.error("login_session time:%d head error:%s", 1000 * time_cost, utils.str2hex(info[:6]))
                    return False

                if res != 0:
                    g.last_api_error = "session server login fail, code:%d msg:%s" % (res, message)
                    xlog.warn("login_session time:%d fail, res:%d msg:%s", 1000 * time_cost, res, message)
                    return False

                try:
                    msg_info = json.loads(message)
                    if msg_info.get("full_log"):
                        xlog.debug("keep full log")
                        keep_log(temp=True)
                except Exception as e:
                    xlog.warn("login_session %s json error:%r", message, e)
                    msg_info = {}

                g.http_client.set_session_host(g.server_host)
                g.last_api_error = ""
                xlog.info("login_session %s time:%d msg:%s", self.session_id, 1000 * time_cost, message)
                return True
            except Exception as e:
                xlog.exception("login_session e:%r", e)
                time.sleep(1)

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Check g.last_api_error / log message for the server's res code and msg (e.g. auth failure) and fix credentials in the x-tunnel config
  2. Verify account status (quota/activation) on the provider dashboard
  3. Confirm g.server_host points to a valid session server
  4. Update XX-Net so protocol_version matches the server
Defensive patterns

Strategy: retry

Validate before calling

if not g.http_client or not g.server_host:
    raise RuntimeError('x-tunnel server host not configured')

Try / catch

ok = session.login_session()
if not ok:
    log.warning('login failed: %s', g.last_api_error)
    # backoff and retry with fresh credentials

Prevention

When it happens

Trigger: Calling proxy_session start()/login_session() when the server rejects the session: wrong/invalid username-password token, expired account, server-side session refusal, or protocol mismatch producing res != 0.

Common situations: Expired or changed XX-Net/x-tunnel account credentials, server maintenance, wrong server host in config, or client version too old sending a protocol the server rejects.

Related errors


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