https://kotlinlang.org logo
#ktor
Title
# ktor
a

Amritansh

02/11/2021, 6:47 PM
Hey Guys, I have question regarding closing HttpClient in ktor. I am working on a logging library using Multiplatform which will be accessing HttpClient frequently to send data to remote server. If I close the client after each request and then create a new client for the next request will that be better over just creating a singleton client and using it for all the request?
e

edenman

02/11/2021, 6:54 PM
i do the latter
m

Marc Knaup

02/11/2021, 9:04 PM
You should reuse
HttpClient
instances as they can manage and coordinate quite a lot of resources.
a

Amritansh

02/12/2021, 6:33 PM
👍 thanks for replying!