WebClient and sending PING

125 views
Skip to first unread message

Paul Antinori

unread,
Feb 8, 2021, 2:27:05 PM2/8/21
to vert.x
Is there a API to send PING using the WebClient API?  I am interested in setting up a interval processor to send PING and handle PONG using the WebClient.  Thanks.

Thomas SEGISMONT

unread,
Feb 9, 2021, 4:53:22 AM2/9/21
to vert.x
Can you explain what you mean with sending PING over HTTP?

Le lun. 8 févr. 2021 à 20:27, Paul Antinori <pant...@gmail.com> a écrit :
Is there a API to send PING using the WebClient API?  I am interested in setting up a interval processor to send PING and handle PONG using the WebClient.  Thanks.

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/ed082cfb-899c-4416-873b-1c7927f99faan%40googlegroups.com.

Paul Antinori

unread,
Feb 11, 2021, 12:11:30 PM2/11/21
to vert.x
We are trying to send the PING on an interval with a worker thread as in the HttpConnection class ping method.  This is a liveliness check and we would tear down the connection if the PING is rejected or timed out.
This is on top of the existing idle timeout fiunctionality on the web client connection.  The question is about how to use the WebClient API to get handle on the HttpConnection.  Thanks for assistance.

Paul

Thomas SEGISMONT

unread,
Feb 12, 2021, 3:52:49 AM2/12/21
to vert.x
It's not possible with the WebClient, I think.

What you could do is creating the WebClient by providing an HttpClient that has a connection handler set. When the handler is called, you can schedule checks for the given connection.

Something like this:

HttpClient httpClient = vertx.createHttpClient(httpClientOptions).connectionHandler(connection-> {
  timerId = vertx.setPeriodic(period, l-> checkConnection(connection));
});
WebClient webClient = WebClient.wrap(httpClient, webClientOptions);

Don't forget to cancel the timer when the connection is closed (with closeHandler)

Paul Antinori

unread,
Feb 12, 2021, 10:32:19 AM2/12/21
to vert.x
Thanks that helps alot, I was not aware about the periodic API on vertx and the wrap API,  and will try it as you suggested.  

Julien Viet

unread,
Feb 15, 2021, 5:21:48 AM2/15/21
to vert.x
Reply all
Reply to author
Forward
0 new messages