Troubleshooting

Common issues and solutions for LX

Troubleshooting Guide

Connection Issues

WebSocket Connection Failed

Symptoms:

  • "Connection refused" error
  • WebSocket timeout
  • Cannot connect to ws://localhost:8081

Solutions:

  1. Check if daemon is running:
# Check process
ps aux | grep lxd

# Check port
lsof -i :8081
  1. Start the daemon:
lxd start --config /path/to/config.yaml
  1. Check firewall:
# macOS
sudo pfctl -sr | grep 8081

# Linux
sudo iptables -L -n | grep 8081
  1. Verify endpoint:
# Test WebSocket
wscat -c ws://localhost:8081

# Test REST
curl http://localhost:8080/health

SSL/TLS Certificate Errors

Symptoms:

  • "Certificate verify failed"
  • "Unable to verify the first certificate"

Solutions:

# Update CA certificates
# macOS
brew install ca-certificates

# Linux
sudo apt update && sudo apt install ca-certificates

# Or disable verification (development only!)
export NODE_TLS_REJECT_UNAUTHORIZED=0

Connection Drops

Symptoms:

  • Frequent disconnections
  • "Connection reset by peer"

Solutions:

  1. Implement reconnection logic:
const connect = () => {
  const ws = new WebSocket(url);
  ws.onclose = () => setTimeout(connect, 1000);
};
  1. Send heartbeats:
setInterval(() => ws.send('{"type":"ping"}'), 30000);
  1. Check network stability:
ping -c 100 dex.lux.network

Order Issues

Order Rejected

Error: "Insufficient balance"

{"error": "insufficient_balance", "required": "1000.00", "available": "500.00"}

Solution: Ensure account has sufficient funds including fees.


Error: "Price out of bounds"

{"error": "price_out_of_bounds", "min": "0.01", "max": "1000000.00"}

Solution: Adjust price within allowed range.


Error: "Size below minimum"

{"error": "size_below_minimum", "minimum": "0.001", "provided": "0.0001"}

Solution: Increase order size to meet minimum.


Error: "Self-trade prevented"

{"error": "self_trade_prevented"}

Solution: Your order would match against your own. Adjust price or cancel existing order.

Order Not Filling

Possible causes:

  1. Limit price too aggressive:

    • Buy orders: price too low
    • Sell orders: price too high
  2. Insufficient liquidity:

# Check order book depth
lx-cli orderbook BTC-USD --depth 20
  1. Post-only rejection:
    • Post-only orders rejected if they would take liquidity

Order Stuck in Pending

Solutions:

  1. Check order status:
lx-cli orders --status pending
  1. Cancel and retry:
lx-cli cancel --order-id ord_123
  1. Check network status:
lx-cli status

API Issues

Authentication Failures

Error: "Invalid signature"

Common causes:

  1. Timestamp drift:
// Ensure system time is synchronized
const timestamp = Date.now();
// Timestamp must be within 30 seconds
  1. Wrong signing format:
// Correct format
const message = `${timestamp}${method}${path}${body}`;
const signature = hmacSHA256(secret, message);
  1. Encoding issues:
// Ensure UTF-8 encoding
const body = JSON.stringify(data);  // Not toString()

Error: "API key not found"

Solutions:

  • Verify key is correct (case-sensitive)
  • Check key hasn't been revoked
  • Ensure key has required permissions

Rate Limiting

Error: "Rate limit exceeded"

{"error": "rate_limit_exceeded", "retry_after": 1000}

Solutions:

  1. Implement backoff:
const backoff = async (attempt: number) => {
  const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
  await sleep(delay);
};
  1. Batch requests:
// Instead of multiple single orders
const orders = [order1, order2, order3];
ws.send(JSON.stringify({ type: "batch_orders", data: orders }));
  1. Use WebSocket for real-time data:
// Subscribe once instead of polling
ws.send(JSON.stringify({ type: "subscribe", channel: "orderbook", symbol: "BTC-USD" }));

Timeout Errors

Error: "Request timeout"

Solutions:

  1. Increase timeout:
const response = await fetch(url, { timeout: 30000 });
  1. Check server health:
curl -w "@curl-format.txt" https://api.lux.exchange/health
  1. Use primary endpoint:
Global (GeoDNS): api.lux.exchange
Kansas City DC: Direct colocation available

Balance Issues

Balance Not Updating

Possible causes:

  1. Pending settlement:

    • Wait 1-2 blocks (~1-2 seconds)
  2. Funds in open orders:

# Check reserved balance
lx-cli balances --show-reserved
  1. Cache issues:
# Force refresh
lx-cli balances --no-cache

Incorrect Balance Shown

Solutions:

  1. Reconcile with blockchain:
lx-cli reconcile --account 0x...
  1. Check all positions:
lx-cli positions --all
  1. Verify deposits:
lx-cli deposits --status pending

SDK Issues

Installation Failures

Python:

# Use virtual environment
python -m venv venv
source venv/bin/activate
pip install lux-dex

TypeScript:

# Clear npm cache
npm cache clean --force
rm -rf node_modules package-lock.json
npm install

Rust:

# Update toolchain
rustup update
cargo clean
cargo build

Go:

# Clear module cache
go clean -modcache
go mod download

Build Errors

C++ missing dependencies:

# macOS
brew install cmake nlohmann-json websocketpp asio

# Linux
sudo apt install cmake nlohmann-json3-dev libwebsocketpp-dev libasio-dev

C missing libwebsockets:

# macOS
brew install libwebsockets

# Linux
sudo apt install libwebsockets-dev

Performance Issues

High Latency

Diagnosis:

# Measure round-trip time
lx-cli ping --count 100

# Check network path
traceroute dex.lux.network

Solutions:

  1. Use colocated servers:

    • AWS us-east-1 for US
    • AWS eu-west-1 for EU
  2. Enable compression:

const ws = new WebSocket(url, { perMessageDeflate: true });
  1. Use binary protocol:
ws.binaryType = 'arraybuffer';

Memory Leaks

Symptoms:

  • Increasing memory usage over time
  • Out of memory errors

Solutions:

  1. Clean up subscriptions:
ws.send(JSON.stringify({ type: "unsubscribe", channel: "orderbook" }));
  1. Limit order book depth:
// Only subscribe to top 10 levels
{ type: "subscribe", channel: "orderbook", depth: 10 }
  1. Use streaming instead of snapshots:
// Incremental updates instead of full snapshots
{ type: "subscribe", channel: "orderbook_delta" }

Still Need Help?

If you've tried the above solutions and still have issues:

  1. Gather diagnostic info:
lx-cli diagnostics > diagnostics.txt
  1. Open GitHub issue with:

    • Error messages
    • Steps to reproduce
    • Diagnostic output
    • SDK/client version
  2. Join Discord for real-time community help