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

Fix keepalive logic #50

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Fix keepalive logic #50

merged 3 commits into from
Dec 20, 2024

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Dec 20, 2024

This PR fixes grpc/grpc-swift#2095.

Motivation

As per the gRPC specification, the server must keep track of pings from each client, and if they go over a threshold, we must send a GOAWAY frame and close the connection. We must reset the number of ping strikes every time the server writes a headers or data frame. However, there is a bug in the current keepalive implementation and we are not properly keeping track of when header/data frames are written, so we never reset the strikes, causing the server to always end up closing connections when keepalive pings are enabled.

There was also a second bug where the GOAWAY frame wasn't actually sent to the client because we were closing the connection straight away, and the packet never made it out.

Modifications

This PR fixes a couple of bugs:

  • It keeps track of the appropriate FrameStats as described above
  • It delays the channel close after sending the GOAWAY packet by a tick to make sure it gets flushed and delivered to the client

Results

Fewer bugs!

@gjcairo gjcairo added the 🔨 semver/patch No public API change. label Dec 20, 2024
@gjcairo gjcairo requested a review from glbrntt December 20, 2024 13:23
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small nits but looks great otherwise, thanks Gus!

@gjcairo gjcairo requested a review from glbrntt December 20, 2024 14:13
@gjcairo gjcairo enabled auto-merge (squash) December 20, 2024 14:13
@gjcairo gjcairo merged commit 47e0be1 into grpc:main Dec 20, 2024
22 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempting streaming service with swift server and non-swift client does not work.
2 participants