@@ -68,7 +68,9 @@ async def open(self) -> None:
6868
6969 async def handle_messages ():
7070 try :
71- ws = await ws_connect (self .req .uri )
71+ # Convert HTTPS URL to WSS for WebSocket connection
72+ ws_uri = self .req .uri .replace ("https://" , "wss://" , 1 )
73+ ws = await ws_connect (ws_uri )
7274 self .ws = ws
7375
7476 # Send authentication
@@ -86,7 +88,31 @@ async def handle_messages():
8688 data = json .loads (message )
8789
8890 if data ["type" ] == "metadata" :
89- self .metadata = PrintTopicMetadata (** data )
91+ # Convert column dictionaries to Column objects
92+ columns = []
93+ for col in data .get ("columns" , []):
94+ if isinstance (col , dict ):
95+ # Provide default value for nullable if missing
96+ columns .append (
97+ Column (
98+ name = col .get ("name" , "" ),
99+ type = col .get ("type" , "" ),
100+ nullable = col .get (
101+ "nullable" , True
102+ ), # Default to True if not specified
103+ length = col .get ("length" ),
104+ precision = col .get ("precision" ),
105+ scale = col .get ("scale" ),
106+ )
107+ )
108+ else :
109+ columns .append (col )
110+
111+ self .metadata = PrintTopicMetadata (
112+ type = data ["type" ],
113+ headers = data .get ("headers" , {}),
114+ columns = columns ,
115+ )
90116 deferred_ready .resolve ()
91117
92118 elif data ["type" ] == "data" :
@@ -124,17 +150,7 @@ def columns(self) -> List[Column]:
124150 if self .metadata is None :
125151 return []
126152
127- return [
128- Column (
129- name = column .name ,
130- type = column .type ,
131- nullable = column .nullable ,
132- length = column .length ,
133- precision = column .precision ,
134- scale = column .scale ,
135- )
136- for column in self .metadata .columns
137- ]
153+ return self .metadata .columns
138154
139155 async def close (self ) -> None :
140156 """Closes the WebSocket connection."""
0 commit comments