XX-net/XX-Net · warning
load config %s except:%r
Error message
load config %s except:%r
What it means
get_config_value() tries to json.load a service config file (e.g. data/smart_router/config.json) and read a key; on any error it logs this warning and returns default_value — a soft fallback, not a crash.
Source
Thrown at code/default/launcher/win_compat_suggest.py:71
out = proc.stdout
lines = out.readlines()
return lines
except Exception as e:
xlog.warn("Win10PortReserveSolution run cmd %s error:%r", cmd, e)
return []
@staticmethod
def get_config_value(fn, key, default_value):
if not os.path.isfile(fn):
return default_value
try:
with open(fn, "r") as fd:
dat = json.load(fd)
value = dat.get(key, default_value)
return value
except Exception as e:
xlog.warn("load config %s except:%r", fn, e)
return default_value
def get_service_ports(self):
web_console_port = config.control_port
smart_router_config_fn = os.path.join(data_path, "smart_router", "config.json")
smart_router_socks_port = self.get_config_value(smart_router_config_fn, "proxy_port", 8086)
smart_router_dns_port = self.get_config_value(smart_router_config_fn, "dns_backup_port", 8053)
x_tunnel_config_fn = os.path.join(data_path, "x_tunnel", "client.json")
x_tunnel_port = self.get_config_value(x_tunnel_config_fn, "socks_port", 1080)
return [web_console_port, smart_router_socks_port, smart_router_dns_port, x_tunnel_port]
def is_port_reserve_conflict(self):
cmd = "netsh int ipv4 show excludedportrange protocol=tcp"
lines = self.run_cmd(cmd)
for line in lines:
if not line.startswith(b" "):View on GitHub (pinned to cfa5bc17b6)
Solutions
- Check the printed file path exists and is valid JSON (python -m json.tool).
- Delete/recreate the file and let the service regenerate it.
- Fix permissions on the data directory.
- Accept the default value if the service hasn't initialized yet.
Defensive patterns
Strategy: fallback
Validate before calling
import json, os
def read_conf(fn, key, default):
try:
with open(fn) as f: return json.load(f).get(key, default)
except Exception: return default Try / catch
try:
value = json.load(open(fn)).get(key, default)
except (OSError, ValueError):
value = default # file missing or corrupt; service will regenerate Prevention
- Treat returned defaults as 'config not ready'.
- Don't hand-edit service JSON while the service is writing.
- Regenerate corrupt configs by deleting them.
When it happens
Trigger: The JSON file is missing, empty, unreadable, or malformed; get_service_ports then falls back to defaults like 8086.
Common situations: First run before smart_router wrote its config; config corrupted by a crash mid-write; permission problems on the data dir.
Related errors
- login_session %s json error:%r
- api:%s parse json:%s fail:%r
- APPID_manager, set_appid_not_exist %s
- Enable auto start, create path:%s fail:%r
- loading config e:%r
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/8b4421bfcb7d61bd.
Report an issue: GitHub.