mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
server: graphql-ws: stop sending pings in response to pongs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5882 GitOrigin-RevId: 07fad6a24bb6eed9807e785e8201517126f7c302
This commit is contained in:
parent
56589b9f9a
commit
c3840fe2d1
@ -1004,7 +1004,7 @@ onMessage env enabledLogTypes authMode serverEnv wsConn msgRaw onMessageActions
|
||||
CMStop stopMsg -> onStop serverEnv wsConn stopMsg
|
||||
-- specfic to graphql-ws
|
||||
CMPing mPayload -> onPing wsConn mPayload
|
||||
CMPong mPayload -> onPong wsConn mPayload
|
||||
CMPong _mPayload -> pure ()
|
||||
-- specific to apollo clients
|
||||
CMConnTerm -> liftIO $ WS.closeConn wsConn "GQL_CONNECTION_TERMINATE received"
|
||||
where
|
||||
@ -1016,14 +1016,6 @@ onPing :: (MonadIO m) => WSConn -> Maybe PingPongPayload -> m ()
|
||||
onPing wsConn mPayload =
|
||||
liftIO $ sendMsg wsConn (SMPong mPayload)
|
||||
|
||||
onPong :: (MonadIO m) => WSConn -> Maybe PingPongPayload -> m ()
|
||||
onPong wsConn mPayload = liftIO $ case mPayload of
|
||||
Just message ->
|
||||
when (message /= keepAliveMessage) $
|
||||
sendMsg wsConn (SMPing mPayload)
|
||||
-- NOTE: this is done to avoid sending Ping for every "keepalive" that the server sends
|
||||
Nothing -> sendMsg wsConn $ SMPing Nothing
|
||||
|
||||
onStop :: (MonadIO m) => WSServerEnv -> WSConn -> StopMsg -> m ()
|
||||
onStop serverEnv wsConn (StopMsg opId) = liftIO $ do
|
||||
-- When a stop message is received for an operation, it may not be present in OpMap
|
||||
|
@ -280,6 +280,9 @@ class GraphQLWSClient():
|
||||
if json_msg['type'] == 'ping':
|
||||
new_msg = json_msg
|
||||
new_msg['type'] = 'pong'
|
||||
# Decline to reflect the payload of the ping, because the
|
||||
# graphql-ws specification does not require it
|
||||
new_msg.pop('payload')
|
||||
self.send(json.dumps(new_msg))
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user