title: OkHttpClient not supporting Http 1.1 for Https network calls
body: <p>I am using Retrofit 2 with OkHttpClient. I want to make connection having the <code>keep-alive</code> property, so as to make persistent connection with the server which is Https enabled. </p>
  
  <p>Now my problem arises when I am making a network call to Https end point the request follows Http2.0 protocol and the headers <strong>Connection : keep-alive</strong> 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.</p>
  
  <pre><code> OkHttpClient.Builder okhttpclient = new OkHttpClient.Builder();
   okhttpclient.protocols(Arrays.asList(Protocol.HTTP_1_1));
  </code></pre>
  
  <p>But still the OkHttpClient sends a Http2.0 request to server for Https network calls.</p>
  
  <p>I even tried to keep persistent connection on user end by using the 
  <a href="https://square.github.io/okhttp/3.x/okhttp/okhttp3/ConnectionPool.html" rel="nofollow noreferrer">ConnectionPool</a> class, but didn't find that as a good solution.</p>
  
  <p>I also tried adding a sslSocketFactory to my OkHttpClient for Https requests. That too didn't work out.</p>
  
  <p><strong>How should I force the Http1.1 protocol for my Https requests with OkHttpClient?</strong></p>