enable keep-alive for HTTPS (static sslSocketFactory) #287
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During a migration from HTTP to HTTPS, we noticed that our
JsonRpcHttpClient
-based application was no longer using keep-alive connections.After some research we found Bill Healey's answer on a Stack Overflow post, which explains why: for a connection/socket to be reused, quasi everything about it must constant, including sub-objects attached to the connection.
For SSL in particular the
SSLSocketFactory
object must be the same across calls to theHttpsUrlConnection
. This pull request implements this improvement, which yielded a huge performance boost when using SSL / HTTPS. Instead of using the existingsetSslContext()
context, one must use the newsetSslSocketFactory()
method.The PR does not include a documentation update (could not find an adequate place where to insert) but of course we think that it would be worth it to add a warning about this.