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 e264d6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,9 @@ def recv_frame(self, frame: Frame) -> None:
elif frame.opcode is OP_PING:
# 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:
pong_frame = Frame(OP_PONG, frame.data)
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 e264d6a

Please sign in to comment.