Skip to content

Commit

Permalink
Only send pong if OPEN.
Browse files Browse the repository at this point in the history
  • Loading branch information
dqh-au committed Jan 9, 2024
1 parent 5209b2a commit 6fb32fa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ def recv_frame(self, frame: Frame) -> None:
# 5.5.2. Ping: "Upon receipt of a Ping frame, an endpoint MUST
# send a Pong frame in response"
pong_frame = Frame(OP_PONG, frame.data)
self.send_frame(pong_frame)
if self.state is OPEN:
self.send_frame(pong_frame)

elif frame.opcode is OP_PONG:
# 5.5.3 Pong: "A response to an unsolicited Pong frame is not
Expand Down

0 comments on commit 6fb32fa

Please sign in to comment.