Re: Can tomcat detect disconnection by client side in Async mode?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chuck, On 12/10/2010 5:30 PM, Caldarale, Charles R wrote: > There is a Socket.isOutputShutdown() method that /might/ indicate > that the client sent an RST, but the exact JRE implementation may > well be platform-specific. Failing that, writing to the socket is the > only way I know of to be sure if the client is still listening (and > even that's not a guarantee). This is what I was thinking when I posted to this thread. The problem is that in asynchronous mode, there may not be a thread handling an event when the RST occurs, so the async request may just sit around waiting to be cleaned-up instead of being pro-active. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0FAkwACgkQ9CaO5/Lv0PBXQQCfeNpEW24r/UVVB7YZcvk0qyay xnQAmwX4dewcuXiNbYiRxGh5nrsyMP7M =Pt+1 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Can tomcat detect disconnection by client side in Async mode?
> From: Michael Ludwig [mailto:mil...@gmx.de] > Subject: Re: Can tomcat detect disconnection by client side in Async mode? > Are there any servers at all that proactively notify their > children or threads of aborted connections in order to stop > them from serving them None that I'm aware of, since the TCP/IP stack doesn't pass that information along unless asked. Something on the server side of the connection would have to access the socket in order to see if the other end is still alive, and the request processing thread has control of the socket, so other server code can't really presume to use it. > or at least provide them the opportunity to cooperatively > abort themselves when discovering an aborted connection - > other than by having them attempt to write to the socket? There is a Socket.isOutputShutdown() method that /might/ indicate that the client sent an RST, but the exact JRE implementation may well be platform-specific. Failing that, writing to the socket is the only way I know of to be sure if the client is still listening (and even that's not a guarantee). - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Can tomcat detect disconnection by client side in Async mode?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael, On 12/6/2010 4:11 PM, Michael Ludwig wrote: > Ben schrieb am 05.12.2010 um 14:25 (+0800): >> and send a new request with different parameters. On server side I >> wanna clean the AsynContext held by previous request. > > Will the server even be notified? I still don't know if and how any HTTP > server will be notified of this infamous "user hit the cancel button" > event. I think if the server tries to flush the response buffer, an exception will be thrown. That's a pretty hacky way to detect this state, and isn't really available in an asynchronous context because there's no event that is in progress during which a flush() could be performed. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0CnMwACgkQ9CaO5/Lv0PC1cQCfQk8nBN1oix7Il/V+9BLG5DDV suUAoLbuLuwsPy6W/4jRQKGkml1kXDML =r1v9 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Can tomcat detect disconnection by client side in Async mode?
Justin Randall schrieb am 07.12.2010 um 00:16 (+): > > Without knowing the application and going on standard sockets, > I know from experience without using Async mode that Tomcat does > generate a ClientAbortException when a TCP RST is received from > a client when Tomcat is writing the HTTP response to the client. Which seems to mean that it is only upon request completion, or at any rate after beginning to write the answer, that Tomcat, or rather, the specific thread attempting to write to the socket, has a chance of being notified of an aborted client connection. So, there is no such thing as an active client connection registry maintained by the server, or possibly some other implementation property which a thread could check to find out about the state of the connection, is there? > The client was a CPE which downloaded firmware/config via HTTP > and sent a TCP RST after the first chunk of data if the version > on the server and in the CPE were identical. Not sure if this > is relevant and what the behaviour of your client would be for > "disconnecting" from the server (assuming it's not a web > browser). I'd really like to know the truth about this age-old myth, of which there's an example in this old message back from 2000: RE: STOP button of browser causes connection leak.. http://www.mail-archive.com/orion-inter...@orionserver.com/msg06077.html "One of our engineers said that the web server should pick up on the connection being dead (back to the browser) so should abort the thread." Are there any servers at all that proactively notify their children or threads of aborted connections in order to stop them from serving them, or at least provide them the opportunity to cooperatively abort themselves when discovering an aborted connection - other than by having them attempt to write to the socket? Has anyone ever encountered any server at all caring in such a way about connections? Or is it all just what I labeled it - a myth? > -Original Message- > From: Ben > Date: Sun, 5 Dec 2010 14:25:56 > Any idea about the disconnection handling? Cannot find reference > for this. > > In my application the client may disconnect and send a new > request with different parameters. On server side I wanna clean > the AsynContext held by previous request. Right now only timeout > will do, which is not efficient cos I set the timeout to quite > high value to avoid frequent disconnect / connect. -- Michael Ludwig - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Can tomcat detect disconnection by client side in Async mode?
Just to clarify, I'm not trying to imply that ClientAbortException wouldn't be generated for Async mode in some way but simply that I've only tested TCP RST behaviour in non-Async mode. Sent from my BlackBerry device -Original Message- From: "Justin Randall" Date: Tue, 7 Dec 2010 00:16:01 To: Tomcat Users List Reply-To: "Tomcat Users List" Subject: Re: Can tomcat detect disconnection by client side in Async mode? Hello, Without knowing the application and going on standard sockets, I know from experience without using Async mode that Tomcat does generate a ClientAbortException when a TCP RST is received from a client when Tomcat is writing the HTTP response to the client. The client was a CPE which downloaded firmware/config via HTTP and sent a TCP RST after the first chunk of data if the version on the server and in the CPE were identical. Not sure if this is relevant and what the behaviour of your client would be for "disconnecting" from the server (assuming it's not a web browser). Regards, Justin Randall Sent from my BlackBerry device -Original Message- From: Ben Date: Sun, 5 Dec 2010 14:25:56 To: Tomcat Users List Reply-To: "Tomcat Users List" Subject: Can tomcat detect disconnection by client side in Async mode? Hi there, Any idea about the disconnection handling? Cannot find reference for this. In my application the client may disconnect and send a new request with different parameters. On server side I wanna clean the AsynContext held by previous request. Right now only timeout will do, which is not efficient cos I set the timeout to quite high value to avoid frequent disconnect / connect. Thanks for help. Ben - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Can tomcat detect disconnection by client side in Async mode?
Hello, Without knowing the application and going on standard sockets, I know from experience without using Async mode that Tomcat does generate a ClientAbortException when a TCP RST is received from a client when Tomcat is writing the HTTP response to the client. The client was a CPE which downloaded firmware/config via HTTP and sent a TCP RST after the first chunk of data if the version on the server and in the CPE were identical. Not sure if this is relevant and what the behaviour of your client would be for "disconnecting" from the server (assuming it's not a web browser). Regards, Justin Randall Sent from my BlackBerry device -Original Message- From: Ben Date: Sun, 5 Dec 2010 14:25:56 To: Tomcat Users List Reply-To: "Tomcat Users List" Subject: Can tomcat detect disconnection by client side in Async mode? Hi there, Any idea about the disconnection handling? Cannot find reference for this. In my application the client may disconnect and send a new request with different parameters. On server side I wanna clean the AsynContext held by previous request. Right now only timeout will do, which is not efficient cos I set the timeout to quite high value to avoid frequent disconnect / connect. Thanks for help. Ben - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Can tomcat detect disconnection by client side in Async mode?
Ben schrieb am 05.12.2010 um 14:25 (+0800): > > Any idea about the disconnection handling? Cannot find reference for > this. > > In my application the client may disconnect Nitpick: It may *abort* the TCP connection. Don't know why, but it seems to me that this is only ever called "disconnect" by mistake. > and send a new request with different parameters. On server side I > wanna clean the AsynContext held by previous request. Will the server even be notified? I still don't know if and how any HTTP server will be notified of this infamous "user hit the cancel button" event. Here's a thread back from 2002 in which a user inquired whether a servlet is notified of the "stop button" event: RE: Notification when HTTP client aborted connection? http://www.mail-archive.com/tomcat-u...@jakarta.apache.org/msg71310.html The question arises what the servlet should do on learning the user pressed the stop button? Press the virtual stop button on the database connection? This requires something like a signal being sent to the servlet, or the servlet doing non-blocking database IO, which I'm not sure is implemented anywhere. > Right now only timeout will do, which is not efficient cos I set the > timeout to quite high value to avoid frequent disconnect / connect. http://download.oracle.com/javaee/6/api/javax/servlet/AsyncContext.html http://download.oracle.com/javaee/6/api/javax/servlet/AsyncListener.html Will the container call onComplete or onError on the AsyncListener in this case? Will the container even be notified (by the OS?) of the TCP connection being aborted by the peer? Currently reading this article, might be of interest: Asynchronous servlets in Servlet Spec 3.0 http://www.softwareengineeringsolutions.com/blogs/2010/08/13/asynchronous-servlets-in-servlet-spec-3-0/ -- Michael Ludwig - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Can tomcat detect disconnection by client side in Async mode?
Hi there, Any idea about the disconnection handling? Cannot find reference for this. In my application the client may disconnect and send a new request with different parameters. On server side I wanna clean the AsynContext held by previous request. Right now only timeout will do, which is not efficient cos I set the timeout to quite high value to avoid frequent disconnect / connect. Thanks for help. Ben - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org