For use of the ktor client within an android app s...
# ktor
b
For use of the ktor client within an android app should we ever close the client? https://ktor.io/clients/http-client/call/requests.html For okhttp, we typically reuse one instance of the client throughout the app. Both clients have an initialization cost. Given that cost, it makes sense to me to leave the ktor client open for an application session. Are there any potential consequences?
e
Hi @Brendan Weinstein, Yes, you should do it when you don’t need new requests. All fired requests will be executed.
b
@e5l What is the purpose of closing? If we have a set of requests [A, B, C] that we fire off. We receive responses the same second. 1 minute goes by and we fire off requests [C, D, E]. Are you suggesting I should close the client and re-open (or just get a new instance of HttpClient)?
e
Nope, feel free to keep it open if you need it. Closing is mostly about gracefully termination: when you need to shutdown the app and want to make sure that there are no other requests
👍 1