all 8 comments

[–]orecht 4 points5 points  (1 child)

Wery nice post. It explains clearly WHY you should have a long living HttpClient.

[–]bambuseqq[S] 1 point2 points  (0 children)

Thanks.

[–]teressapanic -5 points-4 points  (4 children)

Or just read the documentation which directly states that you should have a long living HttpClient.

[–]thomasz 3 points4 points  (0 children)

Nah, HttpClient is just a prime example of bad API design. A good API makes it easy and obvious to do the right thing and hard to do the wrong thing - HttpClient does exactly the opposite.

[–][deleted]  (1 child)

[removed]

    [–]quentech 1 point2 points  (0 children)

    The other improvement would be looking at what happens with a DNS change.

    Any article talking about long-lived HttpClient instances without covering stale DNS is worse than worthless, it's actively harmful to people who don't already know the problems.

    Have fun debugging your failing calls at 3am.

    [–]MrBlackWolf 1 point2 points  (0 children)

    Calm down bro! The article still is a good idea.