Re: [chromium-discuss] Websocket ping/pong

1,844 views
Skip to first unread message

Primiano Tucci

unread,
Jul 27, 2017, 5:31:41 AM7/27/17
to bellos...@gmail.com, net-dev
I guess this question is better asked on net-dev@

On Thu, Jul 27, 2017 at 10:17 AM Thomas Bellos <bellos...@gmail.com> wrote:
Hi

Does chrome respond to pings from servers with a pong opcode frame?

Regards

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

Adam Rice

unread,
Jul 27, 2017, 5:36:08 AM7/27/17
to Primiano Tucci, Thomas Bellos, net-dev
Yes. This behaviour is required by the standard.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+unsubscribe@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CA%2ByH71eGFOcsD%2Bm6-jXb%3D1tYyEKNX7Cjq66-kaJcCW3VhbsrCQ%40mail.gmail.com.

Thomas Bellos

unread,
Jul 27, 2017, 5:41:11 AM7/27/17
to net-dev, prim...@chromium.org, bellos...@gmail.com
Thanks
This ping/pong keep alive protocol, is initiated by the client or the server?
I mean, will chrome periodically send ping frames on its own to determine whether the server is up or chrome just responds to pong frames?

Regards

Adam Rice

unread,
Jul 27, 2017, 5:57:33 AM7/27/17
to Thomas Bellos, net-dev, Primiano Tucci
Chrome doesn't currently ever send ping frames. Without knowing whether it was appropriate for the application it might just waste bandwidth and battery. However, there is discussion of doing it in the specific case when we think the network connection has gone down: https://bugs.chromium.org/p/chromium/issues/detail?id=706002

So in Chrome's case, WebSocket-level keep alive is only ever server-initiated. Server-initiated keep-alive has a known problem that in most cases it won't detect if the NAT mapping has been dropped.

Most applications that need keep-alive implement it explicitly in Javascript. A really simple example would be to send an empty message any time there had been no messages sent or received for a minute, and then program the server to respond to an empty message with another empty message. An empty WebSocket message is the same size as a ping, so no extra bandwidth is required to do it like this.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+unsubscribe@chromium.org.
To post to this group, send email to net...@chromium.org.

Thomas Bellos

unread,
Jul 27, 2017, 6:03:01 AM7/27/17
to net-dev, bellos...@gmail.com, prim...@chromium.org
Really helpful information Adam
Right now, I have implemented a mechanism as you describe, but wanted to make sure that it is not an overhead (in case the browser does it already)

Thanks for the help

Kaleb Henderson

unread,
Nov 1, 2017, 3:19:13 PM11/1/17
to prim...@chromium.org, bellos...@gmail.com, net-dev
Dannevirke

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+unsubscribe@chromium.org.

Xiaosha Xing

unread,
Jun 16, 2021, 4:53:01 PM6/16/21
to net-dev, Adam Rice, net-dev, Primiano Tucci, Thomas Bellos
it looks like this is rather old discussion, so I'm wondering whether there is any update on this behavior?

I'm asking because the ws server I built does not send any ping actively at all, but the connection from the chrome does not get disconnected after 1m anymore, it feels like the browser somehow manages to keepalive. Probably not by sending PING message because my server would not respond to it.

Any feedback/reference would be appreciated!

On Thursday, July 27, 2017 at 11:57:33 AM UTC+2 Adam Rice wrote:
Chrome doesn't currently ever send ping frames. Without knowing whether it was appropriate for the application it might just waste bandwidth and battery. However, there is discussion of doing it in the specific case when we think the network connection has gone down: https://bugs.chromium.org/p/chromium/issues/detail?id=706002

So in Chrome's case, WebSocket-level keep alive is only ever server-initiated. Server-initiated keep-alive has a known problem that in most cases it won't detect if the NAT mapping has been dropped.

Most applications that need keep-alive implement it explicitly in Javascript. A really simple example would be to send an empty message any time there had been no messages sent or received for a minute, and then program the server to respond to an empty message with another empty message. An empty WebSocket message is the same size as a ping, so no extra bandwidth is required to do it like this.

On 27 July 2017 at 18:41, Thomas Bellos <bellos...@gmail.com> wrote:
Thanks
This ping/pong keep alive protocol, is initiated by the client or the server?
I mean, will chrome periodically send ping frames on its own to determine whether the server is up or chrome just responds to pong frames?

Regards
--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.

To post to this group, send email to net...@chromium.org.

Adam Rice

unread,
Jun 16, 2021, 8:38:06 PM6/16/21
to Xiaosha Xing, net-dev, Primiano Tucci, Thomas Bellos
There's been no change in our WebSocket implementation. Something elsewhere may have changed.
Reply all
Reply to author
Forward
0 new messages