Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsMultiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1704184/#msg_1704184
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 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
]]>Jochen Hiller2015-08-08T09:30:08-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1704185/#msg_1704185
John Cocula2015-08-08T09:51:06-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1704209/#msg_1704209
I think we all agree that we should get rid off Apache HttpClient 3 - thanks for highlighting this.
Regarding the question of the best replacement: So far we had documented that Apache HttpClient 4 should be used: https://www.eclipse.org/smarthome/documentation/development/bindings/dependencies.html
But there were reasons why some bindings used the Jetty library instead. I think I just recalled them: 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).
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!
Cheers,
Kai
]]>Kai Kreuzer2015-08-08T21:03:09-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1705511/#msg_1705511
K]]>Karel Goderis2015-08-17T09:53:37-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1705743/#msg_1705743
John Cocula wrote on Sat, 08 August 2015 05:51
Makes perfect sense to trim the bloat, as long as whatever HTTP client library is chosen allows for manually catching and redirecting 307 codes as the Nest API requires. I would have used just org.openhab.io.net.http.HttpUtil.executeUrl had it not been for this requirement.
Could this be a default implementation in org.openhab.io.net.http.HttpUtil.executeUrl for a HTTP 307 return?
]]>Jochen Hiller2015-08-18T17:51:51-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1705744/#msg_1705744
Kai Kreuzer wrote on Sat, 08 August 2015 17:03
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.
Bye, Jochen]]>Jochen Hiller2015-08-18T17:56:52-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1705746/#msg_1705746
karel goderis wrote on Mon, 17 August 2015 05:53
There are a few bindings-to-be-approved (OH2) that also use an HTTP client in the context of JSON-RPC and REST clients. But they can easily (I hope) be switched over.
K
good point. I only checked the bindings actually in ESH and openHAB2 master, not any forks/pending PRs.
Maybe we can help with a good sample binding (like avmfritz) how to use Jetty client.
Bye, Jochen
]]>Jochen Hiller2015-08-18T18:01:30-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1705755/#msg_1705755
The Helios binding uses WS-Notification implementation from the Apache CXF library (that is pure SOAP, not clear what http client that is, and no clue how to switch that over)
The HDAnywhere binding relies on org.eclipse.smarthome.io.net.http.HttpUtil
The Miele binding is based on JSON-RPC, implemented via java.net.HttpURLConnection
The ATSAdvanced binding (will not be published due to SDK license constraints) is based on the Apache CXF as well
]]>Karel Goderis2015-08-18T20:21:52-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1735343/#msg_1735343
https://github.com/eclipse/smarthome/issues/1689]]>Svilen Valkanov2016-06-17T13:24:19-00:00Re: Multiple HttpClients used in Eclipse SmartHome and bindings - get rid off?
https://www.eclipse.org/forums/index.php/mv/msg/1069192/1763777/#msg_1763777
I think the topic can be closed.]]>Svilen Valkanov2017-05-19T14:39:51-00:00