title: HTTP/2 with OkHttp
body: <p>I am trying to communicate with a HTTP/2 server using <a href="http://square.github.io/okhttp/" rel="noreferrer">OkHttp</a> client.</p>
  
  <p>Added to Maven POM:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
    &lt;groupId&gt;com.squareup.okhttp3&lt;/groupId&gt;
    &lt;artifactId&gt;okhttp&lt;/artifactId&gt;
    &lt;version&gt;3.2.0&lt;/version&gt;
  &lt;/dependency&gt;    
  </code></pre>
  
  <p>And this is my test code:</p>
  
  <pre class="lang-java prettyprint-override"><code>OkHttpClient client = new OkHttpClient();
  Request request = new Request.Builder().url("https://http2.akamai.com/demo").build();
  Response response = client.newCall(request).execute();
  System.out.println("Protocol: " + response.protocol());
  System.out.println(response.body().string());
  </code></pre>
  
  <p>But when I run it it prints:</p>
  
  <blockquote>
    <p>Protocol: http/1.1</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>This browser is not HTTP/2 enabled.</p>
  </blockquote>
  
  <p>Environment: OpenJDK 8 on Linux.</p>
  
  <p>Do you need something additional? I saw something called "ALPN" but did not quite understand the concept.</p>