[QUESTION] Regarding pongWait Time in the Examples
eltfshr opened this issue · 2 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
In the examples, it seems like new read deadline is set after receiving pong:
ws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })
My question is why is it not set right after ping is sent. This might be a misconception on my part, but shouldn't time-out be set after sending ping so that it waits for the responding pong? If it is set after receiving pong, then most of the time-out is wasted in between the interval of pings, and the real time left for new pong to respond is pongWait - pingPeriod.
CC: @riflowth, @XiaoXuxxxx, @Porping
Expected Behavior
I expected the time-out to be set when sending ping instead of receiving pong.
Steps To Reproduce
No response
Anything else?
No response
@GreenMarmot
I am just wondering about something and I will illustrate my confusion in the diagram below:
Is the Pong Wait
not the specific time to wait after the server sends a ping to the client???
According to the implementation in the link below, we don't start the timer to count the timeout between ping periods.
https://github.com/gorilla/websocket/blob/main/examples/chat/client.go#L114-L119
I think this question has been sufficiently answered. Closing out