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

kills currently active connections #8

Closed
imoverclocked opened this issue Oct 28, 2016 · 2 comments
Closed

kills currently active connections #8

imoverclocked opened this issue Oct 28, 2016 · 2 comments

Comments

@imoverclocked
Copy link

If I run example (go 1.7.1) and I run: while curl http://127.0.0.1:8080 ; do date; done

Then, I see:

Serving HTTP
^CGot signal:interrupt
Stopping listener
Waiting on server

(expected)

...
Hello HTTP!
Fri Oct 28 21:44:54 UTC 2016
Hello HTTP!
Fri Oct 28 21:44:54 UTC 2016
curl: (52) Empty reply from server

Which means the already accepted connection was interrupted mid-stream.

Looking into the bowels of net/http, it seems somewhat impossible because go c.serve(ctx) has no way of waiting on in-flight requests. There are a few issues open currently to try and fix this issue though:

golang/go#4674
golang/go#11219

The problem is that you can't just wait on http.Serve().

@imoverclocked
Copy link
Author

https://github.com/tylerb/graceful does what you think it should... except that it takes a timeout.

@hydrogen18
Copy link
Owner

The intent of this package is stop the listening socket. The handling of any other sockets that have been opened as a result of that one is not in the scope of this package. I choose to solve this problem outside of the application layer, namely by using connection draining on a load balancer before issuing the stop command to my software.

Pull requests that add additional logic and tests to handle such cases are welcome.

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

No branches or pull requests

2 participants