Our mobile apps need to make 2 different HTTPS requests at the same time. We would like to make sure that only 1 connection is used. Our server supports HTTP/2.
On iOS, everything works well: only 1 connection is established.
On Android, our app is establishing 2 different connections.
Is it possible to achieve the same also on Android?
UPDATE:
I found out the reason: Android's recommended http client HttpUrlConnection
doesn't support HTTP/2!
What recommendation do you have for using HTTP/2 on Android?
System.setProperty("http.keepAlive","true");
You will need to maintain the connection and take care ofurlConnection.disconnect();
yourself. -- I removed my answer in order to add this comment (it will get more attention- people usually look for unanswered questions) because I am a bit uncertain about the results of this suggestion. I simply read the docs -- I have never had any issues with connections or connection pools in the past... so I really haven't dug too deep. – BarnsOkHttp
supports HTTP/2. – BarnsOKHttp
:: github.com/square/okhttp – Barns