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 using tcp keepalives instead of heartbeats #47

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

tanmaykm
Copy link
Member

AMQP allows heartbeats to be disabled completely, provided the server allows that.
But it is essential to have an alternative to detect network disconnections and stale
connections. In this PR, we switch on TCP keepalives on the connection (optional but
enabled by default) and allow heartbeats to be switched off. Heartbeats are still
enabled by default though.

The connection method has these new parameters to allow that:

connection(;
    heartbeat = true,
    keepalive = DEFAULT_KEEPALIVE_SECS,
)
  • heartbeat: true to enable heartbeat, false to disable. Can also be set to a positive integer,
    in which case it is the heartbeat interval in seconds. Defaults to true. If false, ensure
    keepalive is enabled to detect dead connections. This parameter is negotiated with the server.
  • keepalive: true to enable TCP keepalives, false to disable. Can also be set to a positive integer,
    in which case it is the keepalive interval in seconds. Defaults to DEFAULT_KEEPALIVE_SECS.

AMQP allows heartbeats to be disabled completely, provided the server allows that.
But it is essential to have an alternative to detect network disconnections and stale
connections. In this PR, we switch on TCP keepalives on the connection (optional but
enabled by default) and allow heartbeats to be switched off. Heartbeats are still
enabled by default though.

The `connection` method has these new parameters to allow that:

```julia
connection(;
    heartbeat = true,
    keepalive = DEFAULT_KEEPALIVE_SECS,
)
```

- `heartbeat`: `true` to enable heartbeat, `false` to disable. Can also be set to a positive integer,
    in which case it is the heartbeat interval in seconds. Defaults to `true`. If `false`, ensure
    `keepalive` is enabled to detect dead connections. This parameter is negotiated with the server.
- `keepalive`: `true` to enable TCP keepalives, `false` to disable. Can also be set to a positive integer,
    in which case it is the keepalive interval in seconds. Defaults to `DEFAULT_KEEPALIVE_SECS`.
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2021

Codecov Report

Merging #47 (655ac4a) into master (6145773) will decrease coverage by 0.16%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
- Coverage   82.18%   82.02%   -0.17%     
==========================================
  Files           9        9              
  Lines        1016     1029      +13     
==========================================
+ Hits          835      844       +9     
- Misses        181      185       +4     
Impacted Files Coverage Δ
src/protocol.jl 86.83% <94.11%> (-0.21%) ⬇️
src/types.jl 96.31% <0.00%> (-0.60%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6145773...655ac4a. Read the comment docs.

@tanmaykm tanmaykm merged commit 4388aec into master Nov 16, 2021
@delete-merged-branch delete-merged-branch bot deleted the tan/checkstaleconn branch November 16, 2021 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants