Ok, thank you
Nel
2015-11-24 5:46 GMT+01:00 Stuart Douglas <sdouglas(a)redhat.com>:
----- Original Message -----
> From: "Nel Taurisson" <nel.taurisson(a)gmail.com>
> To: "Stuart Douglas" <sdouglas(a)redhat.com>
> Cc: undertow-dev(a)lists.jboss.org
> Sent: Tuesday, 24 November, 2015 3:22:02 PM
> Subject: Re: [undertow-dev] SSE close task
>
> Ok, I understand : the only way to figure out that a client connection is
> closed is by sending a message as sending will eventually fail.
>
> Reading what your saying, even if the client is disconnected, the first
> attempt to send a message will not fail (from the server point of view),
is
> this correct ?
Generally no, depending on how the client closed the connection. If the
client sends an RST immediately on close then the first write will fail.
Otherwise the RST will not be sent till the client receives a message from
the server, so from the servers point of view it is the second write that
fails.
>
> Does that mean that the server cannot fully determine that the client
> received a message ?
No, but you are never going to get the sort of guarantee anyway, as the
client could crash in between an sending an ACK and actually processing the
data.
Stuart
>
> Thanks
> Nel
>
>
>
> 2015-11-24 1:16 GMT+01:00 Stuart Douglas <sdouglas(a)redhat.com>:
>
> > I have commented on the JIRA, but will include it here for anyone who
is
> > following:
> >
> > The close listener is called, however due to the nature of SSE and TCP
> > this behavior is not super intuitive.
> >
> > Basically when the close() is called on the client side the client
sends a
> > FIN to the server, however as the server is not expecting any more data
> > from the client this has no effect (in fact the client may have already
> > sent a FIN if connection:close was sent).
> >
> > From the servers point of view the socket is still functioning
normally,
> > up until the point where it attempts to send some data. When this
happens
> > the client will response with an RST. Unfortunately the server still
has no
> > idea that the socket is broken, as the RST arrives after the data has
been
> > sent (unless the data is very large). When the server attempts to send
for
> > the second time after the client has closed the connection it will
receive
> > an IOException from the RST, the connection will be closed and the
listener
> > invoked.
> >
> > If you want to detect this in a timely manner your only real option is
> > some kind of heartbeat message, due to the way TCP and SSE work there
is
> > not really any other options.
> >
> >
> > Stuart
> >
> > ----- Original Message -----
> > > From: "Nel Taurisson" <nel.taurisson(a)gmail.com>
> > > To: "Stuart Douglas" <sdouglas(a)redhat.com>
> > > Cc: undertow-dev(a)lists.jboss.org
> > > Sent: Tuesday, 24 November, 2015 8:31:35 AM
> > > Subject: Re: [undertow-dev] SSE close task
> > >
> > > Ok, thanks, here's the JIRA with a failing test attached as a patch:
> > >
> > >
https://issues.jboss.org/browse/UNDERTOW-589
> > >
> > > Nel
> > >
> > > 2015-11-23 7:46 GMT+01:00 Stuart Douglas <sdouglas(a)redhat.com>:
> > >
> > > > This sounds like a bug, can you file a JIRA?
> > > >
> > > >
https://issues.jboss.org/projects/UNDERTOW
> > > >
> > > > Stuart
> > > >
> > > > ----- Original Message -----
> > > > > From: "Nel Taurisson" <nel.taurisson(a)gmail.com>
> > > > > To: undertow-dev(a)lists.jboss.org
> > > > > Sent: Monday, 23 November, 2015 5:00:10 PM
> > > > > Subject: [undertow-dev] SSE close task
> > > > >
> > > > > Hi,
> > > > >
> > > > > I'm playing with the SSE handler and I can't figure how
the close
> > task is
> > > > > working. I thought the close task would be invoked when the
client
> > closes
> > > > > the connection but it doesn't seem to be the case.
> > > > >
> > > > > I slightly modified the example code to register a close task
when a
> > > > > connection is initiated, here's the code :
> > > > >
> > > > > ServerSentEventConnectionCallback callback = new
> > > > > ServerSentEventConnectionCallback() {
> > > > > @Override
> > > > > public void connected(ServerSentEventConnection connection,
String
> > > > > lastEventId) {
> > > > > System.out.println("adding close task on
connection...");
> > > > > connection.addCloseTask(channel ->
System.out.println("goodbye
cruel
> > > > > world..."));
> > > > > }
> > > > > };
> > > > > final ServerSentEventHandler sseHandler =
> > > > > Handlers.serverSentEvents(callback);
> > > > >
> > > > > It appears to me that the close task is only invoked when the
server
> > > > stops,
> > > > > but now when the client closes. Is it the expected behavior ?
If
so,
> > is
> > > > > there any other way to be notified of a client disconnection ?
> > > > >
> > > > > Thanks a lot.
> > > > >
> > > > > Nel
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > undertow-dev mailing list
> > > > > undertow-dev(a)lists.jboss.org
> > > > >
https://lists.jboss.org/mailman/listinfo/undertow-dev
> > > >
> > >
> >
>