#!/usr/bin/env python3
"""Debug Redis connection for Genesis."""
import redis
import sys
sys.path.insert(0, '/mnt/e/genesis-system/core')

try:
    from secrets_loader import get_redis_config
    config = get_redis_config()
except ImportError:
    print("[X] secrets_loader not available")
    sys.exit(1)

print(f"--- Debugging Redis Connection to {config.host}:{config.port} ---")

# Try 1: SSL True
print("\nAttempt 1: SSL=True, ssl_cert_reqs=None")
try:
    r = redis.Redis(
        host=config.host, port=config.port,
        password=config.password, username="default",
        ssl=True, ssl_cert_reqs=None, socket_timeout=5
    )
    print("Ping:", r.ping())
    print("SUCCESS")
except Exception as e:
    print(f"FAILED: {e}")

# Try 2: SSL False
print("\nAttempt 2: SSL=False")
try:
    r = redis.Redis(
        host=config.host, port=config.port,
        password=config.password, username="default",
        ssl=False, socket_timeout=5
    )
    print("Ping:", r.ping())
    print("SUCCESS")
except Exception as e:
    print(f"FAILED: {e}")
