Websocket Ping Pong

2,209 views
Skip to first unread message

Gerben Kegel

unread,
Feb 3, 2016, 3:27:47 AM2/3/16
to vert.x
In various topics I read that websocket ping/pong is implemented in Vertx and that a user does not need to worry about this. This is true if the client pings the server. The servers sends back a pong and everything is cool. But it does not work the other way around. If our client looses its internet connection it takes far too long for the server to discover that the client is gone. So we'd like to also send pings from the server to the client. This seems to be something we do need to worry about, since vertx does not seem to do so. But if we send a ping to the client manually, and the client returns with a pong, this pong is intensionally ignored by vertx. My question is why? Can vertx at least call the frameHandler on a pong so I can handle it myself? Or am I doing something wrong and do I need to monitor the websocket connection in any other way?

Gerben Kegel

unread,
Feb 15, 2016, 3:39:14 AM2/15/16
to vert.x
The answer is that you don't need to worry about it. Simply set the IdleTimeout and the connection is closed when the client disapears:

http://vertx.io/docs/apidocs/io/vertx/core/net/TCPSSLOptions.html#setIdleTimeout-int-



Op woensdag 3 februari 2016 09:27:47 UTC+1 schreef Gerben Kegel:

Ion Larratt

unread,
Feb 15, 2016, 10:51:40 PM2/15/16
to vert.x
I have same question as OP and I'm pretty sure, that IdleTimeout is not the right answer. Especially, if we use WebSocket for pushing updates to client, so server initiates sending data to client and client don't send ping frames.

Asher Tarnopolski

unread,
Feb 16, 2016, 3:44:16 AM2/16/16
to vert.x
ion, are you saying that sending heartbeats isn't mandatory for websocket clients?  

Ion Larratt

unread,
Feb 16, 2016, 8:34:14 AM2/16/16
to vert.x
Yes, server must ping clients and receive pong from them.

Asher Tarnopolski

unread,
Feb 16, 2016, 8:57:48 AM2/16/16
to vert.x
i've never seen an implementation where server is the one responsible for heartbeats. but i didn't work with websockets a lot. is this a common practice? 
sounds strange.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/Ws7py-vUMNk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e2eea347-25a8-4083-9456-110147cacbac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ion Larratt

unread,
Feb 16, 2016, 10:48:10 AM2/16/16
to vert.x
Server must send ping frames, because client may send pings or not. That means server can't know exactly, if client connection is still alive.
Also, read about ping and pong frames here:
Reply all
Reply to author
Forward
0 new messages