Fix redis ssl issues
This commit is contained in:
@@ -365,6 +365,7 @@ class AlertEventConsumer:
|
||||
|
||||
# Redis-based rate limiting implementation
|
||||
try:
|
||||
import ssl
|
||||
import redis.asyncio as redis
|
||||
from datetime import datetime, timedelta
|
||||
from app.core.config import Settings
|
||||
@@ -372,7 +373,13 @@ class AlertEventConsumer:
|
||||
# Connect to Redis using proper configuration with TLS and auth
|
||||
settings = Settings()
|
||||
redis_url = settings.REDIS_URL
|
||||
redis_client = await redis.from_url(redis_url, decode_responses=True)
|
||||
|
||||
# Handle SSL/TLS for self-signed certificates
|
||||
connection_kwargs = {"decode_responses": True}
|
||||
if redis_url and redis_url.startswith("rediss://"):
|
||||
connection_kwargs["ssl_cert_reqs"] = ssl.CERT_NONE
|
||||
|
||||
redis_client = await redis.from_url(redis_url, **connection_kwargs)
|
||||
|
||||
# Rate limit keys
|
||||
hour_key = f"alert_rate_limit:{tenant_id}:{alert_type}:hour:{datetime.utcnow().strftime('%Y%m%d%H')}"
|
||||
|
||||
Reference in New Issue
Block a user