Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpsUrlConnection and keep-alive
    primarykey
    data
    text
    <p>I am using <code>com.sun.net.httpserver.HttpsServer</code> in my current project which deals with client-authentification etc.. Currently it only prints out the clients address/port, so that I can check if one TCP-connection is used for multiple requests (<code>keep-alive</code>) or if a new connection is established for every request (and thus a new SSL-handshake is made every time). When I use FireFox to make multiple request against the server I can see that keep-alive is working. So the server part works fine with GET and POST-requests.</p> <p>If I use <code>HttpURLConnection</code> to make a request against the Server (in this case using <strong>no</strong> SSL) <code>keep-alive</code> works, too: Only one connection is established for multiple sequentially started requests.</p> <p>But if I use <code>HttpsURLConnection</code> (using exactly the same code, but <strong>using</strong> SSL) then <code>keep-alive</code> is not working anymore. So for each request a new connection is established, although I am using the same <code>SSLContext</code> (and <code>SSLSocketFactory</code>):</p> <pre><code>// URL myUrl = ... // SSLContext mySsl = ... HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection(); conn.setUseCaches(false); conn.setSSLSocketFactory(mySsl.getSocketFactory()); conn.setRequestMethod("POST"); // send Data // receive Data </code></pre> <p>How do I force <code>HttpsURLConnection</code> to use <code>keep-alive</code> because many requests will lead to many SSL-handshakes which is a real performance issue?</p> <p>Update (2012-04-02): Instead of calling <code>mySsl.getSocketFactory()</code> each time, I tried to cache the <code>SSLSocketFactory</code>. But nothing changed. The problem still exists.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload