Skip to content

HiddifyCli command crashes: unknown load balance strategy #2104

@respuremer

Description

@respuremer

Search first

  • I searched and no similar issues were found

Platform/OS

Linux

OS version

Linux amd64 (Ubuntu 24.04)

Hiddify Version

HiddifyCli v4.1.0

What Happened?

HiddifyCli run -c <subscription_file> always crashes with unknown load balance strategy: because the CLI injects a balancer outbound into the generated sing-box config, but the bundled sing-box 1.13.1 doesn't recognize the balancer's strategy format.

The srun command (raw sing-box) works fine with the same subscription content.

Minimal Reproducible Example (MRE)

  1. Install HiddifyCli v4.1.0 on Linux amd64
  2. Create a subscription file with any valid proxy URIs (e.g., a simple vless config)
  3. Run: HiddifyCli run -c subscription.txt

Expected Behavior

HiddifyCli starts, parses the subscription, and connects.

Additional Context

Actual Behavior

Running in standalone mode
Open http://localhost:6756/ui/?secret= in your browser
Saving config to /home/ubuntu/data/current-config.json <nil>
ERROR[0000] H CORE manager start outbound/balancer[balance]: unknown load balance strategy:
Error in start service manager start outbound/balancer[balance]: unknown load balance strategy:

Root Cause

The generated config at ~/data/current-config.json contains:

{
  "type": "balancer",
  "tag": "balance",
  "strategy": ""
}

The strategy field is an empty string. sing-box 1.13.1 expects either a valid strategy object or the field to be absent.

Workaround

Use HiddifyCli srun -c <config.json> with a manually crafted sing-box config (bypasses the HiddifyCli pipeline). However, this skips the full parsing pipeline (WARP, fragment, DNS overrides).

Alternatively, let HiddifyCli run fail, then patch the saved config to remove the balancer outbound and run with srun:

# Let it generate the config (will fail)
timeout 10 HiddifyCli run -c subscription.txt

# Patch: remove balancer
python3 -c "
import json
d = json.load(open('data/current-config.json'))
d['outbounds'] = [o for o in d['outbounds'] if o.get('type') != 'balancer']
json.dump(d, open('/tmp/patched.json','w'))
"

# Run with srun
HiddifyCli srun -c /tmp/patched.json

Note: the patched config may still crash with a nil pointer dereference if route rules reference the removed balance outbound tag.

Environment

  • HiddifyCli v4.1.0
  • hiddify-sing-box 1.13.1
  • Linux amd64 (Ubuntu 24.04, AWS EC2)
  • Subscription contains: vless, vmess, trojan, shadowsocks URIs

Additional Context

This does NOT affect the Hiddify mobile/desktop app, which uses the gRPC-based core service (start() via CoreClient) rather than the CLI run command. The balancer injection appears to be specific to the CLI standalone mode.

Application Config Options

N/A — using default HiddifyCli options, no -d flag passed.
Command: HiddifyCli run -c subscription.txt
No custom HiddifyApp config file or URL provided.

Relevant log output

DEBUG[0000] H CORE libbox.Setup success ./tmp ./ ./tmp true
DEBUG[0000] H CORE StartGrpcServerByMode 127.0.0.1:17078 3
DEBUG[0000] H CORE grpcServer started on 127.0.0.1:17078
INFO[0000] Server listening on %s127.0.0.1:17078
DEBUG[0000] H CORE HiddifySettingsJson&{ <nil>} EOF
Running in standalone mode
Open http://localhost:6756/ui/?secret= in your browser
WARN[0000] H CORE grpcServer already started
Saving config to /home/ubuntu/data/current-config.json <nil>
ERROR[0000] H CORE manager start outbound/balancer[balance]: unknown load balance strategy:
Error in start service manager start outbound/balancer[balance]: unknown load balance strategy:

When attempting to workaround by patching the generated config (removing the balancer outbound) and running with srun:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x...]

goroutine 1 [running]:
...
os/signal.loop()
        os/signal/signal_unix.go:23 +0x13

Generated config snippet showing the problematic outbound:

{
  "type": "balancer",
  "tag": "balance",
  "strategy": ""
}

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions