11import asyncio
2- import ssl
2+
33from contextlib import asynccontextmanager
44from controllers .heartbeat_controller import (
55 INSTANCE_ID ,
@@ -40,11 +40,8 @@ async def lifespan(app: FastAPI):
4040 """
4141 app .state .event_queue_connection = connect_to_redis_event_queue ()
4242 app .state .room_connection = await connect_to_redis_room_service ()
43- # Create SSL context that verifies certificates properly
44- app .state .ssl_context = ssl .create_default_context ()
45- app .state .ssl_context .check_hostname = False
46- app .state .ssl_context .verify_mode = ssl .CERT_NONE
47- app .state .websocket_manager = WebSocketManager ( app .state .ssl_context )
43+
44+ app .state .websocket_manager = WebSocketManager ()
4845
4946 await app .state .websocket_manager .connect ()
5047
@@ -141,8 +138,7 @@ async def terminate_user_match(
141138 return {"message" : "match has been terminated" }
142139
143140
144-
145- if get_envvar ("ENVIRONMENT" ) == "DEV" :
141+ if get_envvar ("ENVIRONMENT" ) == "DEV" :
146142 # --- Redis Debugging Endpoints
147143 @app .get ("/print-all" )
148144 async def print_all_from_redis_aioredis ():
@@ -151,6 +147,7 @@ async def print_all_from_redis_aioredis():
151147 and returns them. Also prints them to the server console.
152148 """
153149 result = {}
150+
154151 async def printall (r , result ):
155152 async for key in r .scan_iter ("*" ):
156153 try :
@@ -162,10 +159,12 @@ async def printall(r, result):
162159 elif key_type == "hash" :
163160 value = await r .hgetall (key )
164161 elif key_type == "list" :
165- value = await r .lrange (key , 0 , - 1 ) # Get all elements of the list
162+ value = await r .lrange (
163+ key , 0 , - 1
164+ ) # Get all elements of the list
166165 print (" Value (list elements):" )
167166 for item in value :
168- print (f" - { item } " ) # Decode list items
167+ print (f" - { item } " ) # Decode list items
169168 else :
170169 value = f"<{ key_type } type>"
171170 print (f" Value: { value } " )
@@ -175,11 +174,12 @@ async def printall(r, result):
175174 except Exception as e :
176175 print (f"Error processing key { key } : { e } " )
177176 result [key ] = f"<error: { str (e )} >"
177+
178178 await printall (app .state .event_queue_connection , result )
179179 await printall (app .state .room_connection , result )
180180
181181 return result
182-
182+
183183 @app .delete ("/flush-all" )
184184 async def flush_all_redis ():
185185 """
@@ -192,6 +192,3 @@ async def flush_all_redis():
192192 return {"message" : "All Redis databases have been flushed successfully" }
193193 except Exception as e :
194194 return {"error" : f"Failed to flush Redis: { str (e )} " }
195-
196-
197-
0 commit comments