Skip to content

About

Persistent local TCP relay for ZCode api.z.ai Happy Eyeballs timeout (macOS + Linux)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

ZCode Local Bridge (macOS + Linux)

Persistent local TCP relay for ZCode to fix zai_oauth_required / ETIMEDOUT login failures described in zai-org/feedback#116.

Problem

ZCode's bundled Node/undici uses Happy Eyeballs (autoSelectFamily) with a 250ms attempt budget. If IPv6 is dead and IPv4 RTT to api.z.ai is >250ms, connections time out before the TCP handshake finishes.

Solution

  1. Bind a relay on 127.0.0.2:443 (local connect ≪ 250ms).
  2. Map api.z.ai → 127.0.0.2 in /etc/hosts.
  3. Forward raw TCP to upstream IPv4 for api.z.ai.
  4. Persist via LaunchDaemon (macOS) or systemd (Linux).

Install

Requires root (port 443 + system service + hosts):

sudo bash ./install.sh
./status.sh

Then fully quit and reopen ZCode, and Connect to Z.ai.

Uninstall

sudo bash ./uninstall.sh

Layout

Path Role
bridge.js TCP relay
install.sh / uninstall.sh / status.sh OS-detecting helpers
systemd/zcode-bridge.service Linux unit template (install rewrites ExecStart with detected node)
com.zai.zcode-bridge.plist Example macOS plist (install regenerates with detected node)

Installed locations

macOS Linux
Script /Library/Application Support/zcode-bridge/bridge.js /usr/local/lib/zcode-bridge/bridge.js
Service /Library/LaunchDaemons/com.zai.zcode-bridge.plist /etc/systemd/system/zcode-bridge.service
Logs /var/log/zcode-bridge.log journalctl -u zcode-bridge

Reboot persistence

  • macOS: plist RunAtLoad + KeepAlive
  • Linux: systemctl enable → WantedBy=multi-user.target

About

Persistent local TCP relay for ZCode api.z.ai Happy Eyeballs timeout (macOS + Linux)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages