Skip to content

Commit 8445229

Browse files
authored
subscribe updates
headers are added to the websockets connect method keep alive message is handled without crashing
1 parent 72d491d commit 8445229

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python_graphql_client/graphql_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ async def subscribe(
9292
)
9393

9494
async with websockets.connect(
95-
self.endpoint, subprotocols=["graphql-ws"]
95+
self.endpoint,
96+
subprotocols=["graphql-ws"],
97+
extra_headers=self.__request_headers(headers)
9698
) as websocket:
9799
await websocket.send(connection_init_message)
98100
await websocket.send(request_message)
99101
async for response_message in websocket:
100102
response_body = json.loads(response_message)
101103
if response_body["type"] == "connection_ack":
102104
logging.info("the server accepted the connection")
105+
elif response_body["type"] == "ka":
106+
logging.info("the server sent a keep alive message")
103107
else:
104108
handle(response_body["payload"])

0 commit comments

Comments
 (0)