Skip to content
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

Allow configuring TCP Keep-Alive related properties in the Ballerina HTTP Client #7460

Open
TharmiganK opened this issue Dec 11, 2024 · 0 comments

Comments

@TharmiganK
Copy link
Contributor

TharmiganK commented Dec 11, 2024

Problem

The TCP Keep-Alive can be enabled for a HTTP connection made by a Ballerina HTTP Client:

import ballerina/http;

final http:Client clientEP = check new("http://localhost:9090", socketConfig = {keepAlive: true});

But the following TCP Keep-Alive related properties are read from the OS and currently there is no way to configure them in Ballerina:

  • tcp_keepalive_time: Time (in seconds) a connection needs to be idle before TCP starts sending keepalive probes.
  • tcp_keepalive_intvl: Interval (in seconds) between individual keepalive probes.
  • tcp_keepalive_probes: Number of probes to be sent before declaring the connection dead.

These configuring the above properties can be useful in the following scenarios:

  • When we need to keep a connection alive (without sending data) for a long time, and make sure intermediate hops doesn't break the connection when its being idle, using TCP Keep-Alive is a good option. For example, if there is a firewall in the middle, we need to send the keep alive probes before the firewall timed out.
  • When a connection is not working for some reason after sometime, the client can identify it without much delay when keep alive probes are not working and if needed they can recreate the connection. Otherwise, the client will identify it only after sending some data over the broken connection. This may cause the request to timeout or fail immediately.

Proposed Solution

The Ballerina Client uses netty internally and the above properties can be configured in the event-loop using the EpollChannelOptions. But this will only work on linux based systems.

Version

Ballerina SwanLake Update 5

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

1 participant