You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2023/06/20 12:45:33 UTC

[Bug 66659] New: Tomcat does not send FIN message upon request by client to close TCP connection

https://bz.apache.org/bugzilla/show_bug.cgi?id=66659

            Bug ID: 66659
           Summary: Tomcat does not send FIN message upon request by
                    client to close TCP connection
           Product: Tomcat 10
           Version: 10.1.8
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: aritzbastida@gmail.com
  Target Milestone: ------

We are using Tomcat 10 + Spring Boot 3.1.0 to implement a notification
mechanism, based on SSE (Server-Sent Events).

However, when the client agent (browser) tries to close the connection sending
a TCP FIN message, the server (Tomcat) answers just an ACK, instead of ACK+FIN. 

As a result, the server application (REST controller) does not even notice that
the socket is being closed on the client side, and it will be able to send
subsequent notifications (PSH messages).

If client and server are directly connected, the client will respond with a RST
upon next notification, and the server socket will finally be closed. 

But, if a proxy (such as F5 or HA Proxy) lies between the two, the proxy will
silently discard PSH messages and the backend application will "think" that the
notification was successfully delivered to the client. On client side, the
connection will remain in FIN_WAIT_2 state for hours.

For demonstration purposes, I can attach a minimal Spring Boot application
showing this behavior.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 66659] Tomcat does not send FIN message upon request by client to close TCP connection

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66659

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
The issue is that Tomcat won't see the effects of the FIN until it tries to
read from the socket. That won't happen until Tomcat tries to read the next
request. And that will never happen as with SSE the current response
(effectively) never ends so Tomcat never gets as far as trying to read the next
request.

If Tomcat tried to read earlier then it should see the FIN and be able to act
on it but handling the results of that early read when there is pipe-lined HTTP
data is going to be "interesting".

Architecturally I'm not even sure that it is possible to fix this for HTTP/1.1.
I have a few ideas but they involve extensive low-level changes and I haven't
fully thought through the concurrency issues involved.

A simpler solution (and quicker for you to implement) should be switching to
HTTP/2. The multiplexing nature of HTTP/2 means that Tomcat is, effectively,
always trying to read the input and will see the close of either the stream or
the connection.

Switching to WebSocket is another option but one that is almost certainly
rather more work for you.

I'm leaning towards closing this as WONTFIX but I'll leave it open for now to
allow others to comment.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 66659] Tomcat does not send FIN message upon request by client to close TCP connection

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66659

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Resolving as WONTFIX as per my previous comment.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org