Skip to content

Respond to ping request during non-blocking call #7320

Answered by Dreamsorcerer
wenleix asked this question in Q&A
Discussion options

You must be logged in to vote

It does autoping, but as you've spotted, this only happens inside the .receive() method:

await self.pong(msg.data)

I'm not sure if there's really any other way to do it. We can't see the ping message until we read it from the websocket, so how would we know how to respond before this call is made? e.g. We would need to constantly read all messages from the reader prematurely, but if there are a lot of non-ping messages, then this could cause a memory issue, as we now have to store all the pending messages in memory.

I'd suggest that you need to rethink your implementation to work within these constraints. e.g. If it's norm…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dreamsorcerer
Comment options

Answer selected by Dreamsorcerer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants