Skip to content

enable TCP keepalive #1274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ehennum opened this issue Nov 26, 2020 · 1 comment
Closed

enable TCP keepalive #1274

ehennum opened this issue Nov 26, 2020 · 1 comment

Comments

@ehennum
Copy link
Contributor

ehennum commented Nov 26, 2020

Set keepalive at the TCP level to maintain the enode or loadbalancer connection.

Create two new wrapper classes in com.marklogic.client.impl:

  • MarkLogicSSLSocketFactory extends SSLSocketFactory
  • MarkLogicSocketFactory extends SocketFactory

Each of the wrapper classes:

  • Has package visibility
  • Delegates to the base class
  • Has a package-visible constructor that takes an instance of the base class and sets a private field
  • Overrides the createSocket() factory methods to
    • Construct the socket by delegating to the factory method of the field
    • Configure the constructed socket by calling socket.setKeepAlive(true)
    • Return the configured socket

During initialization of the OkHttpClient.Builder within OkHttpServices:

  • Modify the calls to clientBldr.sslSocketFactory() to pass new MarkLogicSSLSocketFactory(sslContext.getSocketFactory())
  • Add an else case (where sslContext is null) that calls clientBldr.socketFactory(new MarkLogicSocketFactory(SocketFactory.getDefault()))

This change should be fully backward compatible.

See internal issues: MLAAS-2580 and RFE-4350

@ehennum
Copy link
Contributor Author

ehennum commented Dec 2, 2020

Merged into master, ready to ship as 5.3.2

ehennum pushed a commit that referenced this issue Dec 2, 2020
georgeajit pushed a commit that referenced this issue Dec 2, 2020
@ehennum ehennum closed this as completed Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants