-
Notifications
You must be signed in to change notification settings - Fork 184
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
[Access] Configure ws connection in ws controller #6750
[Access] Configure ws connection in ws controller #6750
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6750 +/- ##
==========================================
- Coverage 41.26% 41.22% -0.04%
==========================================
Files 2061 2061
Lines 182702 182728 +26
==========================================
- Hits 75384 75333 -51
- Misses 101010 101077 +67
- Partials 6308 6318 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
// message is received from the client, allowing the server to continue waiting | ||
// for further pong messages within the new deadline. | ||
func (c *Controller) configureConnection() error { | ||
// Set the initial read deadline for the first pong message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also set a close handler here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that we should think aboutclose handler
as part of our error handling subtask. The default close handler
sends a close message back to the peer.
func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
if h == nil {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
return nil
}
}
c.handleClose = h
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let`s put this in #6642 just not to forget it.
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6638-ws-connection-configuring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
LGTM! Let's add tests for this in this PR as they're related #6757 |
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6638-ws-connection-configuring
This changes is included into PR #6757 |
Closes: #6638
Context
This PR implements the initial
WebSocket
connection configuration for the newWebSocket controller
. The changes focus on setting up timeouts and ensuring the connection remains responsive, preventing the server from blocking indefinitely while waiting for the client to send or receive messages:configureConnection:
Sets an initial
read deadline
to prevent waiting indefinitely for a pong message.Establishes a
Pong handler
that resets the read deadline each time a pong is received, keeping the connection alive.Write Deadline Timeout:
Adds
SetWriteDeadline
to ensure write operations time out if not completed withinwriteWait
, preventing resource exhaustion from slow or unresponsive clients.