| Disconnects after sleep | System suspended gateway | Run as systemd service |
| "Session expired" | Auth token expired | Re-authenticate the platform |
Diagnosing the Issue
# Check detailed status
openclaw status --verbose
# Gateway: running (PID 12345)
# Uptime: 4h 23m
# Platform Status:
# WhatsApp: ✅ connected (session: valid)
# Telegram: ❌ disconnected (reason: network timeout)
# Discord: ✅ connected (latency: 45ms)
# Slack: ⚠️ reconnecting (attempt 3/5)
# Check recent errors
openclaw logs --level error --since 1h
# Check network connectivity
openclaw diagnostics network
# → Internet: ✅ reachable
# → DNS: ✅ resolving
# → WhatsApp API: ✅ reachable
# → Telegram API: ❌ timeout (check firewall)
# → Discord API: ✅ reachable
Platform-Specific Reconnection
WhatsApp
# Check WhatsApp connection
openclaw platform whatsapp status
# If session expired, re-pair
openclaw platform whatsapp pair
# → Scan the QR code or enter the pairing code
# If database is corrupted
openclaw platform whatsapp reset --keep-contacts
openclaw platform whatsapp pair
Telegram
# Reconnect Telegram
openclaw platform telegram reconnect
# If bot token changed
openclaw platform telegram setup
# → Enter new bot token from @BotFather
# Check webhook
openclaw platform telegram webhook-status
Discord
# Reconnect Discord
openclaw platform discord reconnect
# If bot was removed from server
# Re-invite via the OAuth2 URL:
openclaw platform discord invite-url
Auto-Reconnection Settings
# ~/.openclaw/config.yaml
gateway:
reconnect:
enabled: true
max_attempts: 10
initial_delay: 5s # Wait before first retry
max_delay: 300s # Max wait between retries
backoff_multiplier: 2 # Double the delay each attempt
keepalive:
enabled: true
interval: 30s # Ping every 30 seconds
timeout: 10s # Consider disconnected after 10s
health_check:
enabled: true
interval: 60s # Check all platforms every minute
auto_restart: true # Auto-restart failed platforms
Running as a System Service
The most reliable way to prevent disconnections is running OpenClaw as a systemd service:
# Install as systemd service
openclaw service install
# Or manually create the service file
sudo cat > /etc/systemd/system/openclaw.service << EOF
[Unit]
Description=OpenClaw AI Assistant Gateway
After=network.target
[Service]
Type=simple
User=openclaw
ExecStart=/usr/local/bin/openclaw start --no-daemon
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable openclaw
sudo systemctl start openclaw
# Check service status
sudo systemctl status openclaw
Monitoring and Alerts
# Get notified about disconnections
monitoring:
alerts:
on_disconnect:
enabled: true
channels:
- email: admin@company.com
- sms: "+1-555-0123" # For critical alerts
cooldown: 300s # Don't spam alerts
on_reconnect:
enabled: true
channels:
- email: admin@company.com
Troubleshooting Persistent Disconnections
# Full diagnostic
openclaw diagnostics full
# → System: OK (CPU: 12%, RAM: 340MB/8GB)
# → Network: OK (latency: 23ms)
# → Gateway: Running (PID 12345)
# → Platforms:
# WhatsApp: Session valid, last message 2m ago
# Telegram: Webhook active, last update 30s ago
# Discord: WebSocket open, heartbeat OK
# → Model: Responding (Ollama, 450ms avg)
# → Memory DB: OK (142 entries, 4.2MB)
# → Skills: 8 active, 0 errors
# Check for port conflicts
lsof -i :3000
# Check firewall rules
sudo ufw status
sudo iptables -L | grep 3000
# Test outbound connectivity
curl -v https://api.telegram.org
curl -v https://discord.com/api/v10/gateway
| Persistent Issue | Solution |
| Disconnects every few hours | Enable keepalive in config |
| Disconnects on network change | Use gateway.reconnect.enabled: true |
| Disconnects after system sleep | Run as systemd service |