Skip to content

enable TCP keepalive #1274

@ehennum

Description

@ehennum

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions