-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
How to properly close HTTP Chunked Encoding stream? #5020
Comments
@vladfaust I modified your example to see, to what client the server wants to send a response to. Another thing is that I haven't found any method which could be used to check whether a client is still connected. I tried server = HTTP::Server.new(port) do |context|
req_time = Time.now
puts "Server: got request #{req_time}"
begin
loop do
puts "Server: writing response # #{req_time}"
context.response.puts "foobar\n"
context.response.flush
sleep 1
end
rescue ex
puts "Server rescued from #{ex}"
end
end Output:
|
This can be fixed, but someone will need to send a PR. I'm sure we are missing a few |
While digging that issue I found that there is fix for it on |
The example no longer reproduces.
It continues looping forever. It was probably fixed by #4768 |
Closing then! Thanks ❤️ |
I want to implement a HTTP Chunked Encoding client reconnecting to a server every 3 seconds. Despite of rescuing everywhere, it still throws
Broken pipe (Errno)
errors. What is the proper way to close an infinite stream so a server knows it and reconnect to the server afterwards?My usecase is streaming from Twitter Stream API.
Related to #4991.
Try it yourself:
Logs:
The text was updated successfully, but these errors were encountered: