{"record":{"id":"ef0ced63d41ffc90","repo":"XX-net/XX-Net","slug":"api-s-fail-s-t-d","errorCode":null,"errorMessage":"api:%s fail:%s t:%d","messagePattern":"api:(.+?) fail:(.+?) t:(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"code/default/x_tunnel/local/proxy_session.py","lineNumber":1195,"sourceCode":"    try:\n        upload_post_data = json.dumps(req_info)\n        upload_post_data = encrypt_data(upload_post_data)\n\n        start_time = time.time()\n        while time.time() - start_time < 30:\n            content, status, response = g.http_client.request(method=\"POST\", host=g.config.api_server, path=path,\n                                                              headers={\"Content-Type\": \"application/json\"},\n                                                              data=upload_post_data, timeout=5)\n            if status >= 400:\n                time.sleep(1)\n                continue\n            else:\n                break\n\n        time_cost = time.time() - start_time\n        if status != 200:\n            reason = \"status:%r\" % status\n            xlog.warn(\"api:%s fail:%s t:%d\", path, reason, time_cost)\n            g.last_api_error = reason\n            return False, reason\n\n        content = decrypt_data(content)\n        if isinstance(content, memoryview):\n            content = content.tobytes()\n\n        content = utils.to_str(content)\n        try:\n            info = json.loads(content)\n        except Exception as e:\n            g.last_api_error = \"parse json fail\"\n            xlog.warn(\"api:%s parse json:%s fail:%r\", path, content, e)\n            return False, \"parse json fail\"\n\n        res = info[\"res\"]\n        if res != \"success\":\n            g.last_api_error = info[\"reason\"]","sourceCodeStart":1177,"sourceCodeEnd":1213,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_session.py#L1177-L1213","documentation":"call_api performed an HTTP request to the control-plane API and got a non-200 status (including exceptions/None responses from the loop). It logs path, 'status:%r' reason and time cost, sets g.last_api_error, and returns (False, reason).","triggerScenarios":"Any of check_report_status / request_balance / req_reset_password / req_order_handler / req_transfer_handler / req_get_history_handler hitting a non-200: 5xx from server, 4xx auth errors, timeouts surfacing as non-200 status.","commonSituations":"Server outage or maintenance, expired auth token, network blocking the API host, or redirects not followed.","solutions":["Inspect g.last_api_error / log for the exact status code; 5xx means server issue, retry later","Verify network reachability of the API host","Re-login to refresh session/token if status is 401/403","Update XX-Net if API endpoint changed"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import socket\nsocket.create_connection((api_host, 443), timeout=5).close()  # preflight reachability","typeGuard":null,"tryCatchPattern":"ok, reason = call_api(path)\nif not ok:\n    if 'status:5' in str(reason):\n        time.sleep(backoff); retry()","preventionTips":["Retry non-200 API calls with exponential backoff","Re-login on 401/403 to refresh tokens","Surface g.last_api_error to the user"],"tags":["x-tunnel","http","api","status-code"],"backgroundTag":"http-non-200-response","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}