Skip to content

Conversation

@fbac
Copy link
Collaborator

@fbac fbac commented Jul 7, 2025

Add keepalive configuration to blockchain client initialization using functional options pattern

Refactors the blockchain.NewClient() constructor to use a functional options pattern with ClientOption parameters instead of directly accepting WebSocket URLs. The changes introduce new configuration functions WithWebSocketURL() and WithKeepAliveConfig() that allow configuring TCP keep-alive settings for WebSocket connections. The implementation adds a custom WebSocket dialer with configurable TCP keep-alive behavior, and updates all client initialization calls across the codebase to use the new pattern. In several locations, TCP keep-alive is explicitly disabled by setting Enable: false in the keep-alive configuration.

📍Where to Start

Start with the refactored NewClient function in client.go to understand the new functional options pattern and keep-alive configuration implementation.


Macroscope summarized 180d8fe.

@fbac fbac requested a review from a team as a code owner July 7, 2025 16:03
@graphite-app
Copy link

graphite-app bot commented Jul 7, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@mkysel
Copy link
Collaborator

mkysel commented Jul 7, 2025

Can you give me the context? We are disabling it explicitly and enabling by default? Is this related to the restarts we see?

@fbac
Copy link
Collaborator Author

fbac commented Jul 7, 2025

Can you give me the context? We are disabling it explicitly and enabling by default? Is this related to the restarts we see?

By default it's enabled, I'm only disabling these in short lived connections such as the cli retrieving some data.

In xmtpd it will use the default dialer, and in the indexer those values could be adjusted to the chain block times, etc.

And yep, this is relevant to the restarts we see. I'm not confident this is 100% the solution as I think these are related to the server (blockchain) mostly. In a followup PR I'm also including the backfill on sub recreation.

@fbac fbac merged commit e992bae into main Jul 8, 2025
9 checks passed
@fbac fbac deleted the 07-07-keepalive_client branch July 8, 2025 07:34
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.

3 participants