strawberry
strawberry copied to clipboard
Strawberry must provide server side ping messages
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
Describe the Bug
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.
System Information
- Operating system:
- Strawberry version (if applicable):
Additional Context
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
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Hey @patrick91, just wanted to bring some attention to this, since its been quite a few months.
This is a core bug in the WebSocket protocol implementation which we should fix to stabilize strawberry.