diff --git a/websocket_server/config.py b/websocket_server/config.py index 4acd4be..adbe26e 100644 --- a/websocket_server/config.py +++ b/websocket_server/config.py @@ -29,7 +29,7 @@ DATABASE_URL = "mysql://root:password@172.17.0.1:3306/theapi" redis_connection_pool = redis.ConnectionPool.from_url( REDIS_URL, decode_responses=True, - max_connections=10, + max_connections=10000, socket_timeout=5 ) diff --git a/websocket_server/redis_utils.py b/websocket_server/redis_utils.py index 53746c2..ebdebfe 100644 --- a/websocket_server/redis_utils.py +++ b/websocket_server/redis_utils.py @@ -21,21 +21,22 @@ def redis_subscribe(worker_id): """ redis_client = get_redis_client() - redis_client.config_set("notify-keyspace-events", "KA") - logger.debug(f"Total connections in pool: {len(redis_client.connection_pool._available_connections)}") + redis_client.config_set("notify-keyspace-events", "KEA") + logger.debug(f"Total available in pool: {len(redis_client.connection_pool._available_connections)}") pubsub = redis_client.pubsub() channels = [ - f"__keyspace@0__:worker_status_{worker_id}", - f"__keyspace@0__:worker_queue_{worker_id}" + f"__keyspace@2__:worker_status_{worker_id}", #TODO - The number 2 here is important, it's the Redis DB number which must align with the resid URL in config.py! + f"__keyspace@2__:worker_queue_{worker_id}" ] - + logger.error(f"Subscribed to {channels}") try: pubsub.psubscribe(channels) logger.info(f"Subscribed to Redis keyspace events: {channels}") while not thread_stop_flags.get(worker_id, False): message = pubsub.get_message(timeout=1.0) + logger.debug(message) if message and message["type"] in ["pmessage", "message"]: current_status = redis_client.get(f"worker_status_{worker_id}") logger.debug(f"[{worker_id}] Current Redis status: {current_status}")