@@ -82,6 +82,8 @@ There are two ways to send authentication tokens with websockets depending on th
82
82
init_payload = {' Authorization' : ' token' }
83
83
)
84
84
85
+ .. _websockets_transport_keepalives :
86
+
85
87
Keep-Alives
86
88
-----------
87
89
@@ -125,6 +127,28 @@ Here is an example with a ping sent every 60 seconds, expecting a pong within 10
125
127
pong_timeout=10,
126
128
)
127
129
130
+ Underlying websockets protocol
131
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132
+
133
+ In addition to the keep-alives described above for the apollo and graphql-ws protocols,
134
+ there are also `ping frames `_ sent by the underlying websocket connection itself for both of them.
135
+
136
+ These pings are enabled by default (every 20 seconds) and could be modified or disabled
137
+ by passing extra arguments to the :code: `connect ` call of the websockets client using the
138
+ :code: `connect_args ` argument of the transport.
139
+
140
+ .. code-block :: python
141
+
142
+ # Disabling websocket protocol level pings
143
+ transport = WebsocketsTransport(
144
+ url = ' wss://SERVER_URL:SERVER_PORT/graphql' ,
145
+ connect_args = {" ping_interval" : None },
146
+ )
147
+
148
+ See the `websockets keepalive documentation `_ for details.
149
+
128
150
.. _version 5.6.1 : https://github.com/enisdenjo/graphql-ws/releases/tag/v5.6.1
129
151
.. _Apollo websockets transport protocol : https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md
130
152
.. _GraphQL-ws websockets transport protocol : https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
153
+ .. _ping frames : https://www.rfc-editor.org/rfc/rfc6455.html#section-5.5.2
154
+ .. _websockets keepalive documentation : https://websockets.readthedocs.io/en/stable/topics/timeouts.html#keepalive-in-websockets
0 commit comments