Skip to content

Commit

Permalink
Disable connection keep-alive pings if ping_interval is set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinz01 committed Dec 5, 2024
1 parent 8848ea2 commit 9de1135
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"--config-file",
"config/agent.yml",
"--log-level",
"DEBUG"
"DEBUG",
"--config",
"ping_interval=0"
],
"justMyCode": false
},
Expand All @@ -30,7 +32,9 @@
"--config",
"api_bind_port=7052",
"--config",
"api_static_dir="
"api_static_dir=",
"--config",
"ping_interval=0"
],
"justMyCode": false
},
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This is the changelog for RedPepper.

## [Unreleased]

### Added

- Disable connection keep-alive pings if `ping_interval` is set to `0`.

## [0.3.1]

### Changed
Expand Down
3 changes: 3 additions & 0 deletions src/common/redpepper/common/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ async def _handle_pong(self, message: MessageType) -> None:

async def _ping_periodically(self) -> None:
interval = self.config.ping_interval
if interval == 0:
logger.debug("Not doing periodic ping because ping_interval is 0")
return
logger.debug("Pinging %s every %s seconds", self.remote_address, interval)
while True:
await trio.sleep(interval)
Expand Down

0 comments on commit 9de1135

Please sign in to comment.