Server side ping messages are necessary to keep the websocket connection open on all types of platforms.
The particular platform I'm working with is react-native on Android
React-Native on Android Websockets close due to no server side PING messages within 8-10 seconds.
You can follow the crux of the discussion here: https://discord.com/channels/689806334337482765/1134350180653740065
I have verified the issue with the author of graphql-ws
repo.
I would recommend sending PINGs from strawberry every 6 seconds to account for most types of client websocket timeouts.
Probably would require changes to handlers.py within these lines:
async def handle_connection_init(self, message: ConnectionInitMessage) -> None:
if self.connection_timed_out:
# No way to reliably excercise this case during testing
return # pragma: no cover
if self.connection_init_timeout_task:
self.connection_init_timeout_task.cancel()
if message.payload is not UNSET and not isinstance(message.payload, dict):
await self.close(code=4400, reason="Invalid connection init payload")
return
self.connection_params = message.payload
if self.connection_init_received:
reason = "Too many initialisation requests"
await self.close(code=4429, reason=reason)
return
self.connection_init_received = True
await self.send_message(ConnectionAckMessage())
self.connection_acknowledged = True
async def handle_ping(self, message: PingMessage) -> None:
await self.send_message(PongMessage())
async def handle_pong(self, message: PongMessage) -> None:
pass
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too