xiaozhi-esp32-server/docs/support/troubleshooting.md
lapy ed8c012588 docs: English-first documentation, images, and licensing
- Curated guides under docs/; trim China-only integration docs and screenshots

- Root and main README set aligned with westernized product positioning

- LICENSE text update where applicable
2026-04-25 17:05:22 +01:00

18 KiB

🛠️ Troubleshooting Guide

This comprehensive troubleshooting guide helps you diagnose and fix common issues with Xiaozhi ESP32 Server. Follow the steps systematically to resolve problems quickly.

🔍 Diagnostic Tools

Health Check Commands

# Check server status
curl http://localhost:8000/health

# Check web interface
curl http://localhost:8001

# Check API server
curl http://localhost:8002/api/health

# Check OTA interface
curl http://localhost:8003/xiaozhi/ota/

# Check Docker services
docker-compose ps

# Check system resources
htop
df -h
free -h

Log Analysis

# View server logs
docker-compose logs -f xiaozhi-server

# View specific service logs
docker-compose logs -f manager-api
docker-compose logs -f manager-web

# View system logs
sudo journalctl -u xiaozhi-server -f

# Check error logs
tail -f logs/error.log

🚀 Server Issues

Server Won't Start

Symptoms

  • Server fails to start
  • Error messages during startup
  • Services not responding

Diagnosis Steps

  1. Check Docker Status
# Check Docker is running
docker --version
docker-compose --version

# Check Docker services
docker-compose ps
  1. Check Port Conflicts
# Check if ports are in use
netstat -tulpn | grep :8000
netstat -tulpn | grep :8001
netstat -tulpn | grep :8002
netstat -tulpn | grep :8003
  1. Check System Resources
# Check memory usage
free -h

# Check disk space
df -h

# Check CPU usage
top

Solutions

Port Conflicts:

# Kill processes using ports
sudo fuser -k 8000/tcp
sudo fuser -k 8001/tcp
sudo fuser -k 8002/tcp
sudo fuser -k 8003/tcp

# Or change ports in docker-compose.yml
ports:
  - "8000:8000"  # Change first number

Memory Issues:

# Increase Docker memory limit
# In Docker Desktop: Settings → Resources → Memory

# Or use smaller AI models
ASR:
  WhisperASR:
    model_name: tiny  # Instead of large

Docker Issues:

# Restart Docker
sudo systemctl restart docker

# Clean up Docker
docker system prune -a

# Rebuild containers
docker-compose down
docker-compose up -d --build

Server Crashes Frequently

Symptoms

  • Server stops responding
  • Frequent restarts
  • Error messages in logs

Diagnosis Steps

  1. Check Logs for Errors
# View recent logs
docker-compose logs --tail=100 xiaozhi-server

# Look for specific errors
grep -i "error\|exception\|crash" logs/xiaozhi-server.log
  1. Check Resource Usage
# Monitor resource usage
docker stats

# Check for memory leaks
ps aux | grep python
  1. Check Configuration
# Validate configuration
python -c "import yaml; yaml.safe_load(open('data/.config.yaml'))"

# Check environment variables
env | grep -E "(DB_|REDIS_|OPENAI_)"

Solutions

Memory Issues:

# Optimize memory usage
performance:
  streaming: true
  parallel_processing: false
  cache_responses: true
  preload_models: false

Configuration Errors:

# Reset configuration
cp data/.config.yaml data/.config.yaml.backup
# Edit configuration file
nano data/.config.yaml

Database Issues:

# Check database connection
mysql -u xiaozhi -p -h localhost xiaozhi

# Restart database
docker-compose restart mysql

🔌 ESP32 Connection Issues

ESP32 Won't Connect

Symptoms

  • ESP32 doesn't appear in OTA interface
  • WebSocket connection fails
  • Device shows offline status

Diagnosis Steps

  1. Check Network Connectivity
# Test ESP32 connectivity
ping ESP32_IP_ADDRESS

# Check WiFi signal strength
# On ESP32: Check WiFi.status() in serial monitor
  1. Check WebSocket URL
# Verify WebSocket URL format
# Should be: ws://SERVER_IP:8000/xiaozhi/v1/
# Check in OTA interface: http://localhost:8003/xiaozhi/ota/
  1. Check Server Logs
# Look for connection attempts
docker-compose logs -f xiaozhi-server | grep -i "websocket\|connect"

Solutions

Network Issues:

# Check firewall rules
sudo ufw status
sudo iptables -L

# Allow WebSocket connections
sudo ufw allow 8000

WebSocket URL Issues:

# Update WebSocket URL in ESP32 firmware
# Use correct server IP address
# Format: ws://192.168.1.100:8000/xiaozhi/v1/

ESP32 Firmware Issues:

# Reflash ESP32 firmware
# Download latest firmware from OTA interface
# Use esptool.py to flash
esptool.py --chip esp32s3 --port COM3 --baud 921600 write_flash 0x0 firmware.bin

ESP32 Connects But No Audio

Symptoms

  • ESP32 shows connected
  • No audio input/output
  • Voice commands not working

Diagnosis Steps

  1. Check Audio Configuration
# Check audio settings in web interface
# Go to: http://localhost:8001 → Devices → Your Device
  1. Test Audio Components
# Test microphone
# Check connections: GPIO 15-17
# Verify power: 3.3V, GND

# Test speaker
# Check connections: GPIO 18-20
# Verify amplifier power
  1. Check Audio Processing
# Test ASR provider
curl -X POST http://localhost:8000/api/test/asr \
  -H "Content-Type: application/json" \
  -d '{"audio_file": "test.wav"}'

Solutions

Microphone Issues:

# Check microphone configuration
audio:
  input:
    sample_rate: 16000
    channels: 1
    bit_depth: 16
    buffer_size: 1024
    noise_reduction: true

Speaker Issues:

# Check speaker configuration
audio:
  output:
    sample_rate: 22050
    channels: 1
    bit_depth: 16
    buffer_size: 1024
    volume: 0.8

Audio Processing Issues:

# Restart audio services
docker-compose restart xiaozhi-server

# Check audio dependencies
pip list | grep -E "(whisper|edge-tts|pyaudio)"

🤖 AI Provider Issues

Speech Recognition Not Working

Symptoms

  • No speech recognition
  • Poor accuracy
  • Timeout errors

Diagnosis Steps

  1. Test ASR Provider
# Test WhisperASR
curl -X POST http://localhost:8000/api/test/asr \
  -H "Content-Type: application/json" \
  -d '{"provider": "WhisperASR", "audio_file": "test.wav"}'

# Test OpenAIASR
curl -X POST http://localhost:8000/api/test/asr \
  -H "Content-Type: application/json" \
  -d '{"provider": "OpenAIASR", "audio_file": "test.wav"}'
  1. Check Model Files
# Check Whisper models
ls -la models/whisper/
# Should see: tiny, base, small, medium, large

# Check model integrity
python -c "import whisper; whisper.load_model('base')"
  1. Check API Keys
# Test OpenAI API key
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
  https://api.openai.com/v1/models

Solutions

Model Issues:

# Reinstall Whisper models
pip uninstall whisper
pip install openai-whisper

# Download models
python -c "import whisper; whisper.load_model('base')"

API Key Issues:

# Set API key
export OPENAI_API_KEY=your_api_key_here

# Or add to .env file
echo "OPENAI_API_KEY=your_api_key_here" >> .env

Accuracy Issues:

# Optimize ASR settings
ASR:
  WhisperASR:
    model_name: large        # Use larger model
    language: en            # Specify language
    temperature: 0.0        # Reduce randomness
    compression_ratio_threshold: 2.4
    logprob_threshold: -1.0
    no_speech_threshold: 0.6

Language Model Not Responding

Symptoms

  • No responses to voice commands
  • Timeout errors
  • Poor response quality

Diagnosis Steps

  1. Test LLM Provider
# Test OpenAI LLM
curl -X POST http://localhost:8000/api/test/llm \
  -H "Content-Type: application/json" \
  -d '{"provider": "OpenAILLM", "message": "Hello"}'

# Test LMStudio LLM
curl -X POST http://localhost:8000/api/test/llm \
  -H "Content-Type: application/json" \
  -d '{"provider": "LMStudioLLM", "message": "Hello"}'
  1. Check LLM Configuration
# Check LLM settings in web interface
# Go to: http://localhost:8001 → Model Configuration → LLM
  1. Check Network Connectivity
# Test OpenAI API
curl https://api.openai.com/v1/models

# Test LMStudio
curl http://localhost:1234/v1/models

Solutions

OpenAI Issues:

# Check API key and billing
# Go to: https://platform.openai.com/usage

# Test API key
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
  https://api.openai.com/v1/models

LMStudio Issues:

# Check LMStudio is running
curl http://localhost:1234/v1/models

# Restart LMStudio
# Load a model and enable local API

Response Quality Issues:

# Optimize LLM settings
LLM:
  OpenAILLM:
    model_name: gpt-4o-mini    # Use appropriate model
    temperature: 0.7           # Balance creativity
    max_tokens: 1000          # Sufficient length
    top_p: 1.0                # Use full vocabulary

Text-to-Speech Not Working

Symptoms

  • No audio output
  • TTS errors
  • Poor audio quality

Diagnosis Steps

  1. Test TTS Provider
# Test EdgeTTS
curl -X POST http://localhost:8000/api/test/tts \
  -H "Content-Type: application/json" \
  -d '{"provider": "EdgeTTS", "text": "Hello"}'

# Test OpenAI TTS
curl -X POST http://localhost:8000/api/test/tts \
  -H "Content-Type: application/json" \
  -d '{"provider": "OpenAITTS", "text": "Hello"}'
  1. Check Audio Output
# Test speaker connections
# Check GPIO 18-20 connections
# Verify amplifier power
  1. Check TTS Configuration
# Check TTS settings in web interface
# Go to: http://localhost:8001 → Model Configuration → TTS

Solutions

EdgeTTS Issues:

# Install EdgeTTS
pip install edge-tts

# Test EdgeTTS
python -c "import edge_tts; print('EdgeTTS installed')"

OpenAI TTS Issues:

# Check API key
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
  https://api.openai.com/v1/models

# Test TTS API
curl -X POST https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "tts-1", "input": "Hello", "voice": "alloy"}'

Audio Quality Issues:

# Optimize TTS settings
TTS:
  EdgeTTS:
    voice: en-US-AriaNeural    # Use high-quality voice
    rate: +0%                  # Normal speech rate
    pitch: +0Hz                # Normal pitch
    volume: +0%                # Normal volume

🌐 Network Issues

WebSocket Connection Problems

Symptoms

  • ESP32 can't connect to server
  • Intermittent disconnections
  • Connection timeouts

Diagnosis Steps

  1. Check Network Connectivity
# Test server accessibility
ping SERVER_IP_ADDRESS

# Test WebSocket port
telnet SERVER_IP_ADDRESS 8000
  1. Check Firewall Rules
# Check firewall status
sudo ufw status

# Check iptables rules
sudo iptables -L
  1. Check WebSocket URL
# Verify URL format
# Should be: ws://IP:8000/xiaozhi/v1/
# Check in OTA interface

Solutions

Firewall Issues:

# Allow WebSocket port
sudo ufw allow 8000

# Allow all Xiaozhi ports
sudo ufw allow 8000:8003

Network Configuration:

# Check network interface
ip addr show

# Check routing table
ip route show

# Test DNS resolution
nslookup SERVER_IP_ADDRESS

WebSocket URL Issues:

# Use correct IP address
# Find server IP: ip addr show
# Update ESP32 firmware with correct URL

Slow Response Times

Symptoms

  • Delayed responses
  • High latency
  • Timeout errors

Diagnosis Steps

  1. Check Network Latency
# Test ping latency
ping -c 10 SERVER_IP_ADDRESS

# Test WebSocket latency
# Use browser developer tools
  1. Check Server Performance
# Monitor server resources
docker stats

# Check server logs for performance issues
docker-compose logs -f xiaozhi-server | grep -i "slow\|timeout"
  1. Check AI Provider Performance
# Test AI provider response times
time curl -X POST http://localhost:8000/api/test/llm \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello"}'

Solutions

Network Optimization:

# Optimize network settings
echo 'net.core.rmem_max = 16777216' >> /etc/sysctl.conf
echo 'net.core.wmem_max = 16777216' >> /etc/sysctl.conf
sysctl -p

Server Optimization:

# Optimize server performance
performance:
  streaming: true
  parallel_processing: true
  cache_responses: true
  preload_models: true
  gpu_acceleration: true

AI Provider Optimization:

# Use faster AI models
ASR:
  WhisperASR:
    model_name: base        # Instead of large

LLM:
  OpenAILLM:
    model_name: gpt-4o-mini # Instead of gpt-4o
    max_tokens: 500         # Shorter responses

🔧 Configuration Issues

Configuration File Errors

Symptoms

  • Server won't start
  • Configuration errors in logs
  • Settings not applied

Diagnosis Steps

  1. Validate Configuration
# Check YAML syntax
python -c "import yaml; yaml.safe_load(open('data/.config.yaml'))"

# Check JSON syntax
python -c "import json; json.load(open('data/.config.json'))"
  1. Check Configuration Permissions
# Check file permissions
ls -la data/.config.yaml

# Check file ownership
stat data/.config.yaml
  1. Check Configuration Content
# View configuration
cat data/.config.yaml

# Check for syntax errors
grep -n ":" data/.config.yaml

Solutions

Syntax Errors:

# Fix YAML syntax
# Use online YAML validator
# Check indentation (use spaces, not tabs)

# Example correct syntax:
ASR:
  WhisperASR:
    type: whisper
    model_name: base

Permission Issues:

# Fix permissions
sudo chown $USER:$USER data/.config.yaml
sudo chmod 644 data/.config.yaml

Content Issues:

# Reset configuration
cp data/.config.yaml data/.config.yaml.backup
# Edit configuration file
nano data/.config.yaml

Environment Variable Issues

Symptoms

  • API keys not working
  • Database connection failures
  • Service configuration errors

Diagnosis Steps

  1. Check Environment Variables
# Check all environment variables
env | grep -E "(DB_|REDIS_|OPENAI_)"

# Check specific variables
echo $OPENAI_API_KEY
echo $DB_HOST
echo $REDIS_HOST
  1. Check .env File
# Check .env file exists
ls -la .env

# Check .env content
cat .env
  1. Test Environment Loading
# Test environment loading
python -c "import os; print(os.getenv('OPENAI_API_KEY'))"

Solutions

Missing Variables:

# Create .env file
cat > .env << EOF
OPENAI_API_KEY=your_api_key_here
DB_HOST=localhost
DB_PORT=3306
DB_NAME=xiaozhi
DB_USER=xiaozhi
DB_PASSWORD=your_password
REDIS_HOST=localhost
REDIS_PORT=6379
EOF

Incorrect Variables:

# Update .env file
nano .env

# Restart services
docker-compose restart

Loading Issues:

# Source .env file
source .env

# Or restart shell
exec $SHELL

🆘 Emergency Recovery

Complete System Reset

If nothing else works, you can reset the entire system:

# Stop all services
docker-compose down

# Remove all containers and volumes
docker-compose down -v
docker system prune -a

# Remove data directory
rm -rf data/

# Recreate data directory
mkdir -p data

# Restart services
docker-compose up -d

Configuration Reset

Reset only the configuration:

# Backup current configuration
cp data/.config.yaml data/.config.yaml.backup

# Reset to defaults
cat > data/.config.yaml << EOF
# Default configuration
selected_module:
  ASR: WhisperASR
  LLM: LMStudioLLM
  TTS: EdgeTTS

ASR:
  WhisperASR:
    type: whisper
    model_name: base
    device: auto
    language: null

LLM:
  LMStudioLLM:
    type: openai
    base_url: http://localhost:1234/v1
    api_key: lm-studio
    model_name: llama3.1:8b

TTS:
  EdgeTTS:
    type: edge_tts
    voice: en-US-AriaNeural
    rate: +0%
    pitch: +0Hz
    volume: +0%
EOF

# Restart services
docker-compose restart

Database Reset

Reset the database:

# Stop services
docker-compose down

# Remove database volume
docker volume rm xiaozhi-esp32-server_mysql_data

# Restart services
docker-compose up -d

# Wait for database initialization
sleep 30

# Check database status
docker-compose logs mysql

📞 Getting Help

When to Ask for Help

Ask for help when:

  • You've tried all troubleshooting steps
  • You're getting error messages you don't understand
  • The issue is preventing you from using Xiaozhi
  • You suspect a bug in the software

How to Ask for Help

  1. Gather Information

    • Error messages and logs
    • System information (OS, hardware)
    • Configuration files
    • Steps to reproduce the issue
  2. Create GitHub Issue

    • Go to GitHub Issues
    • Click "New Issue"
    • Fill out the issue template
    • Attach relevant files and logs
  3. Join Community Discussion

Information to Include

When asking for help, include:

  • Operating system and version
  • Hardware (ESP32 board, computer specs)
  • Installation method (Docker, local)
  • Error messages and logs
  • Steps to reproduce the issue
  • What you've tried already

🎯 Quick Reference

Essential Commands

# Check service status
docker-compose ps

# View logs
docker-compose logs -f

# Restart services
docker-compose restart

# Check health
curl http://localhost:8000/health

Common Solutions

  • Port conflicts: Kill processes or change ports
  • Memory issues: Use smaller models or increase RAM
  • Network issues: Check firewall and connectivity
  • Configuration errors: Validate syntax and permissions

Emergency Recovery

  • System reset: docker-compose down -v && docker system prune -a
  • Config reset: Restore from backup or recreate
  • Database reset: Remove volume and restart

Most issues can be resolved with these troubleshooting steps! 🛠️

👉 Next: Community Support →