-
Notifications
You must be signed in to change notification settings - Fork 36
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
add timer for recieving closeok, force close socket after a while #538
Conversation
Main benchmark PR benchmark Keep in mind, these numbers are not representative of LavinMQ's peak performance. |
@@ -143,6 +144,10 @@ module LavinMQ | |||
if @running | |||
process_frame(frame) | |||
else | |||
if (RoughTime.monotonic - @closeok_timer) > 5.seconds |
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.
this only works if the client still sends frames, but imagine a client that just consumes but doesn't properly send the CloseOk frame, eg. because it's busy with other things.. One possibility is to start a new fiber when we close the client, that sleeps 5s, checks if the connection is still open and then force closes it.
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.
The down side is of course that if we closed 1M connections, and thus spawn 1M new fibers, that can be very memory intensive..
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.
or we set a read_timeout
on the socket when we try to gracefully close the client, so the read_loop will raise an TimeoutError if the client is silent.
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 think my last commit adds it in the way you're thinking, not sure how to test it easily
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 this if-statement isn't needed now with the read_timeout
set? Instead we can check if @running == false
, log something about timeout and break the loop? (cleanup
and close_socket
is always done thanks to the ensure
block).
Co-authored-by: Carl Hörberg <carl@84codes.com>
Co-authored-by: Carl Hörberg <carl@84codes.com>
21dc553
to
198dc5e
Compare
No description provided.