Close the underlying tcp connection when rejecting#211
Close the underlying tcp connection when rejecting#211shterrett wants to merge 1 commit intojaspervdj:masterfrom
Conversation
|
The build failure appears to be an issue with CircleCI fetching the stack lts |
|
Is there any reason why |
|
@shterrett if you rebase on top of master CI failures would go away. |
|
I've added a doc note for now ae2aa5e#diff-125df5360210799a9fd1726d6f83c2bdf9388cbbdeeaabd7bf34bf3d1ba94cabR244 |
Historically, I was assuming it would be the task of the framework (WAI/Snap/...) to close the connection once the WebSockets application finishes. I wanted to avoid double closes, but it maybe depends on the specific framework on whether or not that is a bad thing or the second close would just do nothing. But ever since we have the Streams abstraction, I guess it's fine to close that it in either case. |
I just ran into the same issue described in [jaspervdj#211](jaspervdj#211). In my case I had noticed the note about calling `Stream.close` in the `rejectRequest` docs but I didn't realize that the disclaimer applied to `rejectRequestWith` as well. Based on [this comment](jaspervdj#211 (comment)) maybe it makes sense to close the underlying stream when rejecting the request, but short of that maybe this note will help someone else avoid the same issue.
When using this library in conjunction with
servant-websockets, we noticed that after rejecting the request, the connection was held open until it timed out, approximately one minute later. Our current workaround is to accept the connect and then immediatelysendCloseand exit.This adds
rejectAndCloseWithto reject the request and close the underlying tcp connection immediately to avoid the workaround above.