Question on broken connection from client
dfens opened this issue · 4 comments
Here: https://github.com/jruby/jruby-rack/blob/master/src/main/ruby/jruby/rack/response.rb#L178
We can see following code
rescue NativeException => e
# Don't needlessly raise errors because of client abort exceptions
raise unless e.cause.toString =~ /(clientabortexception|broken pipe)/i
ensure
@body.close if @body.respond_to?(:close)
This means that if client connection is broken - there is no exception on server-side (server just does not care if client received response).
My question is - what is the reason for this behaviour? For example i can imagine situation when client posted some data and need to know that it has been processed properly - in such case if connection on response is broken -> we may want to revert change on server side. So this is normal handling of such situations for HTTP requests?
Thank you @kares.
Problem is that I need to know that client connection was broken not between beginning of request (which is handled) and writing response (which is not handled).
I did some monkey patches and tested with client that is writing on port 80 but closes socket before receiving response. but even then I am not getting into NativeException => e (with monkeypatch there). Can you advise me on this? Also - shouldn't this be optional? (same as chunking option), I can imagine situations where changes made by client request should be rollbacked if client did not receive response
yep, you're right it should have been configurable ... will see what I can do, what is the monkey-patch like ?
in terms of not-getting the failure you want, does it come back wrapped to you or something, if not I might not be able to help you without knowing (looking at) your servlet container specifics ... do not expect much!
as you already noted it's now supported on 1.1-stable with e075f34 and 82bf64c ... just pushed a SNAPSHOT you can try out: https://oss.sonatype.org/content/repositories/snapshots/org/jruby/rack/jruby-rack/1.1.17-SNAPSHOT/ release shall come still in 2014!