Skip to content

Commit 1590f7d

Browse files
committed
fix: socket connection timeout
Context: - okhttp uses an HTTP/2 connection to the coder rest api in order to resolves the workspaces. - HTTP/2 uses a single TCP connection for multiple requests (multiplexing). If the connection is idle, the http server can close that connection, with client side ending in a socket timeout if it doesn't detect the drop in time. - similarly on the client side, if the OS goes into sleep mode, the connection might have been interrupted. HTTP/2 doesn't always detect this quickly, leading to stale streams when Toolbox wakes up. Implementation: - we could try to force the client to use HTTP/1 which creates a TCP connection for each request, but from my testing it seems that configuring a retry strategy when a client attempts to reuse a TCP connection that has unexpectedly closed does the job. - resolves #13
1 parent da7656f commit 1590f7d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/kotlin/com/coder/toolbox/sdk/CoderRestClient.kt

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ open class CoderRestClient(
103103
builder
104104
.sslSocketFactory(socketFactory, trustManagers[0] as X509TrustManager)
105105
.hostnameVerifier(CoderHostnameVerifier(settings.tls.altHostname))
106+
.retryOnConnectionFailure(true)
106107
.addInterceptor {
107108
it.proceed(
108109
it.request().newBuilder().addHeader(

0 commit comments

Comments
 (0)