Archlinux OpenClaw Discord and Model Provider Proxy Fix

Problem

The OpenClaw Gateway running on archlinux could start, but Discord behavior was unreliable:

  • Discord gateway login and reconnects were flaky
  • messages sent to the bot were sometimes received but not replied to
  • final Discord reply delivery sometimes failed with fetch failed
  • model execution often timed out or failed during fallback

Observed symptoms included:

  • Discord WebSocket close code 1006
  • fetch failed during Discord startup and reply sending
  • LLM request timed out for openai-codex/*
  • HTTP 403 forbidden: Request not allowed for Anthropic fallback models
  • Gemini fallback auth refresh failures

Investigation

Confirmed on archlinux:

  • direct outbound access to Discord timed out
  • proxying through local sing-box at http://127.0.0.1:5780 worked
  • the openclaw-gateway.service systemd environment did not include proxy variables

Useful checks:

curl -I --max-time 10 https://discord.com/api/v10/gateway
curl -I --max-time 10 -x http://127.0.0.1:5780 https://discord.com/api/v10/gateway
systemctl --user show openclaw-gateway.service -p Environment --no-pager
journalctl --user -u openclaw-gateway.service --since "30 min ago" --no-pager -l

Additional finding:

  • setting channels.discord.proxy=http://127.0.0.1:5780 helped Discord startup, but it was not sufficient by itself
  • provider/model traffic still showed strong signs of missing proxy egress

Root Cause

The archlinux host needed outbound HTTP(S) traffic to go through the local proxy, but the Gateway systemd service was running without proxy environment variables.

As a result:

  • Discord REST/gateway traffic was partially broken
  • model provider traffic could time out or fail unpredictably
  • even when a fallback model succeeded, final reply delivery could still fail

Fix Applied

A systemd drop-in override was added for the Gateway service:

Path:

  • ~/.config/systemd/user/openclaw-gateway.service.d/proxy.conf

Contents:

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:5780"
Environment="HTTPS_PROXY=http://127.0.0.1:5780"
Environment="ALL_PROXY=http://127.0.0.1:5780"
Environment="NO_PROXY=127.0.0.1,localhost,::1"
Environment="http_proxy=http://127.0.0.1:5780"
Environment="https_proxy=http://127.0.0.1:5780"
Environment="all_proxy=http://127.0.0.1:5780"
Environment="no_proxy=127.0.0.1,localhost,::1"

Then reloaded and restarted:

systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service

The existing Discord-specific setting was also kept:

openclaw config set channels.discord.proxy http://127.0.0.1:5780

Verification

After the fix:

  • openclaw-gateway.service returned to:
    • ActiveState=active
    • SubState=running
  • service environment showed proxy variables loaded
  • logs showed:
    • rest proxy enabled
    • gateway proxy enabled
    • logged in to discord as ...
  • user confirmed that Discord interaction succeeded again

Notes

  • If Discord is flaky on this host, check proxy egress before debugging bot config.
  • channels.discord.proxy alone may not be enough when model providers also require proxied outbound access.
  • Anthropic 403 and Gemini OAuth failures may still indicate separate credential issues, but the service-level proxy fix was necessary for overall recovery.