Skip to content

Commit

Permalink
Merge pull request #208 from lightsparkdev/fix/explicittimeout
Browse files Browse the repository at this point in the history
Add explicit timeouts to the Requester
  • Loading branch information
jklein24 authored Sep 23, 2024
2 parents 1fffb04 + 0427a3f commit 8ad4c0b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.lightspark.sdk.core.crypto.NodeKeyCache
import com.lightspark.sdk.core.crypto.nextLong
import com.lightspark.sdk.core.util.getPlatform
import io.ktor.client.HttpClient
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.compression.ContentEncoding
import io.ktor.client.plugins.websocket.WebSockets
import io.ktor.client.request.headers
Expand Down Expand Up @@ -52,6 +53,12 @@ class Requester constructor(
gzip() // Switch to deflate() when https://youtrack.jetbrains.com/issue/KTOR-6999 is fixed
}
install(WebSockets)
install(HttpTimeout) {
// See https://ktor.io/docs/client-timeout.html for more info.
requestTimeoutMillis = 20000
connectTimeoutMillis = 5000
socketTimeoutMillis = 10000
}
}
private val userAgent =
"lightspark-kotlin-sdk/${LightsparkCoreConfig.VERSION} ${getPlatform().platformName}/${getPlatform().version}"
Expand Down

0 comments on commit 8ad4c0b

Please # to comment.