Andy Chan
Andy Chan

Reputation: 287

java okhttp manually close connection issues

When I try to use okhttp to get content from web sites, I found that I am unavailable to manually close the established sessions (using netstat to check), of course I know this is one of feature that natively support by okhttp, but in my case, the project should require to release sessions same as using HTTPURLConnection.close() methods, and I cannot find in okhttpclient.

How can I do it? thanks.

Upvotes: 2

Views: 2771

Answers (1)

Jesse Wilson
Jesse Wilson

Reputation: 40593

Try this:

okHttpClient.connectionPool().evictAll();

Upvotes: 4

Related Questions