immortal-bnb/docs/TROUBLESHOOTING.md
caelum0x bea907f76e feat: Complete production readiness implementation
- Integrated all production features into main application flow
- Added metrics, tracing, caching, and health checks to API server
- Enhanced trade execution with circuit breakers and retry policies
- Integrated database persistence for trades and metrics
- Added structured logging and observability
- Enhanced middleware with missing validators and rate limiters
- Added comprehensive error handling and resilience patterns
2025-11-20 00:35:39 +03:00

4.5 KiB

Troubleshooting Guide

Common issues and solutions for the Immortal AI Trading Bot.

Table of Contents

  1. Bot Won't Start
  2. Database Connection Issues
  3. API Errors
  4. Trading Issues
  5. Performance Issues
  6. Memory/Storage Issues

Bot Won't Start

Symptom

Bot status shows as "stopped" or API returns errors when starting.

Solutions

  1. Check Environment Variables

    # Verify required variables are set
    echo $WALLET_PRIVATE_KEY
    echo $OPENROUTER_API_KEY
    echo $DATABASE_URL
    
  2. Check Logs

    docker-compose logs backend | tail -50
    
  3. Verify Wallet Balance

    # Check if wallet has sufficient BNB
    curl http://localhost:3001/api/bot-status
    
  4. Check Database Connection

    psql $DATABASE_URL -c "SELECT 1"
    

Database Connection Issues

Symptom

Errors like "Connection refused" or "ECONNREFUSED".

Solutions

  1. Verify Database is Running

    docker-compose ps postgres
    
  2. Check Connection String

    # Format: postgresql://user:password@host:port/database
    echo $DATABASE_URL
    
  3. Test Connection

    psql $DATABASE_URL -c "SELECT version()"
    
  4. Check Network

    # If using Docker, ensure services are on same network
    docker network ls
    

API Errors

Symptom

API returns 500 errors or timeouts.

Solutions

  1. Check Service Status

    curl http://localhost:3001/health
    
  2. Review Error Logs

    tail -f logs/error.log
    
  3. Check Rate Limiting

    # Verify you're not hitting rate limits
    curl -v http://localhost:3001/api/bot-status
    
  4. Verify API Key

    # Ensure API key is valid
    curl -H "X-API-Key: your-key" http://localhost:3001/api/bot-status
    

Trading Issues

Symptom

Bot is running but not executing trades.

Solutions

  1. Check AI Confidence

    • Low confidence decisions may result in HOLD
    • Review AI decision logs
  2. Verify Market Conditions

    # Check if tokens have sufficient liquidity
    curl http://localhost:3001/api/discover-tokens
    
  3. Check Safeguards

    • Verify trade amount limits
    • Check stop-loss settings
    • Review risk level
  4. Review Trade Logs

    curl http://localhost:3001/api/trade-logs?limit=10
    

Performance Issues

Symptom

Slow API responses or high latency.

Solutions

  1. Check Database Performance

    # Check for slow queries
    psql $DATABASE_URL -c "
    SELECT query, mean_exec_time 
    FROM pg_stat_statements 
    ORDER BY mean_exec_time DESC 
    LIMIT 10;
    "
    
  2. Review Cache Hit Rate

    # Check Redis stats
    redis-cli INFO stats
    
  3. Check System Resources

    # CPU and memory usage
    docker stats
    
  4. Optimize Queries

    • Add database indexes
    • Review query patterns
    • Enable query caching

Memory/Storage Issues

Symptom

Greenfield storage errors or memory sync failures.

Solutions

  1. Verify Greenfield Connection

    # Check Greenfield RPC
    echo $GREENFIELD_RPC_URL
    
  2. Check Bucket Access

    # Verify bucket exists and is accessible
    echo $GREENFIELD_BUCKET_NAME
    
  3. Review Memory Sync Queue

    # Check metrics
    curl http://localhost:3001/metrics | grep memory_sync
    
  4. Clear Sync Backlog

    # If backlog is too large, may need to process manually
    # Check logs for sync errors
    

Common Error Messages

"Insufficient balance"

Solution: Add BNB to wallet

# Get testnet BNB from faucet
# Mainnet: Transfer BNB to wallet

"Rate limit exceeded"

Solution: Wait for rate limit window to reset or upgrade API plan

"Circuit breaker is OPEN"

Solution: External service is down. Wait for automatic recovery or check service status.

"Database connection timeout"

Solution:

  1. Check database is running
  2. Verify network connectivity
  3. Check connection pool settings

Getting Help

If issues persist:

  1. Check logs: logs/error.log and logs/combined.log
  2. Review metrics: http://localhost:3001/metrics
  3. Check health: http://localhost:3001/api/health
  4. Contact support with:
    • Error messages
    • Log excerpts
    • System configuration
    • Steps to reproduce