Configure keep alive duration for okhttp connection pool to 1 minute.

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
This commit is contained in:
AsamK
2021-01-31 17:03:44 +01:00
committed by Greyson Parrelli
parent cfd4399685
commit 4bb214cb2a

View File

@@ -138,6 +138,7 @@ import javax.net.ssl.X509TrustManager;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionPool;
import okhttp3.ConnectionSpec;
import okhttp3.Credentials;
import okhttp3.Dns;
@@ -1807,6 +1808,8 @@ public class PushServiceSocket {
.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);
}