Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Regarding pongWait Time in the Examples #901

Closed
1 task done
eltfshr opened this issue Feb 27, 2024 · 2 comments
Closed
1 task done

[QUESTION] Regarding pongWait Time in the Examples #901

eltfshr opened this issue Feb 27, 2024 · 2 comments
Labels

Comments

@eltfshr
Copy link

eltfshr commented Feb 27, 2024

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

@eltfshr eltfshr added the bug label Feb 27, 2024
@riflowth
Copy link

riflowth commented Feb 28, 2024

@GreenMarmot
I am just wondering about something and I will illustrate my confusion in the diagram below:

image

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

@jaitaiwan
Copy link

I think this question has been sufficiently answered. Closing out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants