Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off? [message #1704184] |
Sat, 08 August 2015 09:30 |
Jochen Hiller Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Hi all,
I am just working on getting some bindings running on a non-Equinox OSGi runtime environment.
I struggled over that the Eclipse SmartHome framework and some bindings (from ESH, from openHAB2, ignoring openHAB1 for the moment) are using different HttpClients. To minimize the footprint over restricted devices (like Raspberry Pi 1) it is a bad idea to use multiple clients at same time, will increase memory footprint and startup time.
I made a rough analysis of the code base:
# bundles using Apache HttpClient 3.x
$ find . -name "MANIFEST.MF" -exec grep -l "org.apache.commons.httpclient" {} \;
./openhab2-master/git/openhab2/addons/binding/org.openhab.binding.autelis/META-INF/MANIFEST.MF
./openhab2-master/git/openhab2/addons/binding/org.openhab.binding.squeezebox/META-INF/MANIFEST.MF
./openhab2-master/git/openhab2/bundles/core/org.openhab.core/META-INF/MANIFEST.MF
./openhab2-master/git/openhab2/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF
./smarthome-master/git/smarthome/bundles/io/org.eclipse.smarthome.io.net/META-INF/MANIFEST.MF
./smarthome-master/git/smarthome/bundles/ui/org.eclipse.smarthome.ui/META-INF/MANIFEST.MF
# bundles using Apache HttpClient 4.x
$ find . -name "MANIFEST.MF" -exec grep -l "org.apache.http." {} \;
./openhab2-master/git/openhab2/addons/binding/org.openhab.binding.ipp/META-INF/MANIFEST.MF
# bundles using Jetty Client
$ find . -name "MANIFEST.MF" -exec grep -l "org.eclipse.jetty.client" {} \;
./openhab2-master/git/openhab2/addons/binding/org.openhab.binding.avmfritz/META-INF/MANIFEST.MF
I also checked the different footprint of the used http clients:
* Apache HttpClient 3.x: org.apache.commons.httpclient, org.apache.commons.codec (about 600 kB)
* Apache HttpClient 4.x: org.apache.httpcomponents.httpclient, org.apache.httpcomponents.httpcore, org.apache.commons.codec (about 1,5 MB)
* Jetty Client 9.2.x: Jetty Client, Http, IO, Util (about 900 kB)
As HttpClient 3.x is considered as legacy this should be removed long term. So decision would be between Apache HttpClient 4 and Jetty Client. Considering the footprint Jetty would be first choice, but the client libraries might be not so popular like Apache HttpClient.
In general such a change would break the API in one case (HttpUtil.createHttpMethod), but this will not be used until now in ESH, openHAB2 (only 1x used in openHAB1 NEST binding), so no real issue.
What do you think? Is this the effort worth to try to get rid of not needed HttpClients?
Same time new bindings should be asked/enforced to stick on same http client.
Bye, Jochen
|
|
|
|
|
|
|
Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off? [message #1705744 is a reply to message #1704209] |
Tue, 18 August 2015 17:56 |
Jochen Hiller Messages: 11 Registered: July 2009 |
Junior Member |
|
|
Hi Kai,
Kai Kreuzer wrote on Sat, 08 August 2015 17:03
What you have missed is that the Apache HttpClient 4 does not support asynchronous processing of requests - you will need an additional component called asyncclient (https://hc.apache.org/httpcomponents-asyncclient-4.1.x/index.html), which ends up at 2MB with all its dependencies.
Furthermore, the version 4.1 somehow suggests that it is not very actively maintained (not in sync with the HttpClient 4 at least - the issue tracker shows last activity in February this year: https://issues.apache.org/jira/browse/HTTPASYNC/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
These are valid arguments against Apache HttpClient 4.x, I agree. Thanks for pointing to the async stuff missing in my overview.
Kai Kreuzer wrote on Sat, 08 August 2015 17:03
The Jetty client seems to be much more active and modern - it e.g. already comes with HTTP/2 support as well and many other features, see https://webtide.com/http2-support-for-httpclient/. I personally have some positive experiences with using this library (asynchronously) and thus would think that it probably would be a good choice. But I would love to hear some other opinions and experiences as well!
I agree with you, we should give it a try. I will work on a PR to change org.eclipse.smarthome.io.net to use Jetty.
We have then to revise the recommendations at
https://www.eclipse.org/smarthome/documentation/development/bindings/dependencies.html to move over to Jetty.
Bye, Jochen
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04599 seconds