Custom HttpClient option blocks application shutdown
See original GitHub issueCalling:
RequestConfig clientConfig = RequestConfig.custom().setConnectTimeout(600000).setSocketTimeout(600000).build();
Unirest.setHttpClient(HttpClientBuilder.create().setDefaultRequestConfig(clientConfig).build());
Which is the default configuration Unirest uses makes the application unable to exit. 8 Threads (I/O dispatcher 1-8) remain running.
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
You're using HttpClient wrong and it is destabilizing your ...
Once the using block is complete then the disposable object, in this case HttpClient , goes out of scope and is disposed.
Read more >Make HTTP requests using IHttpClientFactory in ASP.NET Core
Options. Use IHttpContextAccessor to access the current request. Create a custom AsyncLocal<T> storage object to pass the data. Use Polly-based ...
Read more >Why is an OPTIONS request sent and can I disable it?
Chrome: Quit Chrome, open an terminal and paste this command: open /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir.
Read more >Apache HttpClient Example - CloseableHttpClient | DigitalOcean
Create HttpGet or HttpPost instance based on the HTTP request type. ... Finally close the apache HttpClient resource.
Read more >Don't use Go's default HTTP client (in production) - Medium
TL;DR: Go's http package doesn't specify request timeouts by default, allowing services to hijack your goroutines. Always specify a custom http.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve tested this locally and it seems to be fixed with new Unirest version
1.3.3
.Before terminating the application, close the event loop by executing
Unirest.shutdown()
first. In your example you can use it inside thecompleted
callback function as well.https://github.com/Mashape/unirest-java#exiting-an-application
2 things: I’ve written the example code and there’s a documentation mistake in the async example. Async examples method
failed()
has to useUnirestException
The example code - application will never terminate because of http-async-clients created threads: