I am using Retrofit 2 with OkHttpClient. I want to make connection having the keep-alive
property, so as to make persistent connection with the server which is Https enabled.
Now my problem arises when I am making a network call to Https end point the request follows Http2.0 protocol and the headers Connection : keep-alive are ignored, but when I make the same request to Http end point the headers are accepted and persistent connection works. So to have Http1.1 protocol for Https calls I added manually this to my OkHttpClient.
OkHttpClient.Builder okhttpclient = new OkHttpClient.Builder();
okhttpclient.protocols(Arrays.asList(Protocol.HTTP_1_1));
But still the OkHttpClient sends a Http2.0 request to server for Https network calls.
I even tried to keep persistent connection on user end by using the ConnectionPool class, but didn't find that as a good solution.
I also tried adding a sslSocketFactory to my OkHttpClient for Https requests. That too didn't work out.
How should I force the Http1.1 protocol for my Https requests with OkHttpClient?