//okhttp/okhttp3/OkHttpClient/Builder/pingInterval
pingInterval¶
[jvm]\ fun pingInterval(interval: Long, unit: TimeUnit): OkHttpClient.Builder
@IgnoreJRERequirement
fun pingInterval(duration: Duration): OkHttpClient.Builder
Sets the interval between HTTP/2 and web socket pings initiated by this client. Use this to automatically send ping frames until either the connection fails or it is closed. This keeps the connection alive and may detect connectivity failures.
If the server does not respond to each ping with a pong within interval
, this client will assume that connectivity has been lost. When this happens on a web socket the connection is canceled and its listener is notified. When it happens on an HTTP/2 connection the connection is closed and any calls it is carrying will fail with an IOException.
The default value of 0 disables client-initiated pings.