XX-net/XX-Net · error
login session fail, status:%r
Error message
login session fail, status:%r
What it means
login_session got a non-200, non-521 HTTP status from the session login API (e.g. 401/403/5xx). The status is recorded in g.last_api_error and the retry loop continues to attempt logins. Typical meanings: authentication failure for the account credentials, expired token, rate limiting, or server-side errors.
Source
Thrown at code/default/x_tunnel/local/proxy_session.py:429
upload_data_head += struct.pack("<H", len(extra_info)) + utils.to_bytes(extra_info)
upload_post_data = encrypt_data(upload_data_head)
content, status, response = g.http_client.request(method="POST", host=g.server_host, path="/data",
data=upload_post_data,
timeout=g.config.network_timeout)
time_cost = time.time() - start_time
if status == 521:
g.last_api_error = "session server is down."
xlog.warn("login session server is down, try get new server.")
g.server_host = None
return False
if status != 200:
g.last_api_error = "session server login fail:%r" % status
xlog.warn("login session fail, status:%r", status)
continue
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:View on GitHub (pinned to cfa5bc17b6)
Solutions
- Inspect the exact status code (401/403 → re-enter credentials; 429 → back off; 5xx → server issue)
- Re-verify the X-Tunnel account credentials/token in config
- Add exponential backoff between login retries instead of a tight continue loop
- Check community/status channels if the API is failing server-side for everyone
Example fix
# before
if status != 200:
g.last_api_error = "session server login fail:%r" % status
xlog.warn("login session fail, status:%r", status)
continue
# after
if status != 200:
g.last_api_error = "session server login fail:%r" % status
xlog.warn("login session fail, status:%r", status)
time.sleep(min(60, 2 ** attempt)) # backoff
continue Defensive patterns
Strategy: retry
Validate before calling
if not credentials_valid():
refresh_x_tunnel_token() # before calling session.start() Try / catch
for attempt in range(5):
if session.start(): break
if '401' in str(g.last_api_error) or '403' in str(g.last_api_error):
re_prompt_credentials(); break
time.sleep(2 ** attempt) Prevention
- Keep X-Tunnel credentials/token current
- Back off between login retries; inspect g.last_api_error for the status code
- Distinguish auth errors (fix credentials) from 5xx (wait/retry)
When it happens
Trigger: Logging in with invalid/expired X-Tunnel credentials, hitting rate limits, or API server errors — any status other than 200/521 from the login endpoint.
Common situations: Changed account password, expired session token reused, too many login attempts, API under maintenance.
Related errors
- login_session time:%d fail, res:%d msg:%s
- login session server is down, try get new server.
- login_session %s json error:%r
- %s %s%s status:%d trace:%s
- front retry %s%s
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/d2b528a5c5c58880.
Report an issue: GitHub.