Skip to content

Commit

Permalink
Configure keep alive duration for okhttp connection pool to 1 minute.
Browse files Browse the repository at this point in the history
The signal http server supports http keep alive, but closes idle
connections after 1 minute.
The default OkHttp connection pool will keep idle connections in the pool
for 5 minutes and doesn't notice it when the server closes connections.
As currently the automatic okhttp retries are disabled, reusing such a
stale connection will be fatal.

Issue is especially severe for incoming calls, which fail because the request
to retrieve the turn servers fails and isn't retried: #10787
  • Loading branch information
AsamK authored and greyson-signal committed Feb 3, 2021
1 parent cfd4399 commit 4bb214c
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -138,6 +138,7 @@

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionPool;
import okhttp3.ConnectionSpec;
import okhttp3.Credentials;
import okhttp3.Dns;
Expand Down Expand Up @@ -1807,6 +1808,8 @@ private static OkHttpClient createConnectionClient(SignalUrl url, List<Intercept
.connectionSpecs(url.getConnectionSpecs().or(Util.immutableList(ConnectionSpec.RESTRICTED_TLS)))
.build();

builder.connectionPool(new ConnectionPool(5, 45, TimeUnit.SECONDS));

for (Interceptor interceptor : interceptors) {
builder.addInterceptor(interceptor);
}
Expand Down

0 comments on commit 4bb214c

Please sign in to comment.