<div dir="ltr">I am trying with Undertow 1.2.0.Beta1 which is available in Maven Central and physical connection termination does not lead to calling "close" listeners.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 21, 2014 at 9:10 PM, Cody Lerum <span dir="ltr"><<a href="mailto:cody.lerum@gmail.com" target="_blank">cody.lerum@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This also happens in Wildfly 8.1 (Undertow 1.0.15) and can happen if<br>
the browser doesn't close the connection when the tab is closed.<br>
Chrome and IE both do this.<br>
<br>
<a href="https://issues.jboss.org/browse/WFLY-3704" target="_blank">https://issues.jboss.org/browse/WFLY-3704</a><br>
<br>
Supposedly fixed in later versions but I haven't upgraded yet to verify.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Oct 21, 2014 at 9:07 AM, Vladimir Tsukur <<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>> wrote:<br>
> One more observation - in case network connection is completely lost in<br>
> between client and server, "close" notifiers are not invoked at all (tried<br>
> by shutting down network connection on the client machine keeping browser<br>
> tab opened). In this case there is no opportunity for a client to send a<br>
> close frame to the server. Is it a bug then? Using Undertow 1.2.0.Beta1<br>
><br>
> On Tue, Oct 21, 2014 at 4:10 PM, Vladimir Tsukur <<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>> wrote:<br>
>><br>
>> Thanks Stuart,<br>
>><br>
>> Did not see this method in 1.0.x since it was added at a later release -<br>
>> tried with latest version and it works well.<br>
>><br>
>> However, I figured out that connection termination works well iif receive<br>
>> setter is set:<br>
>><br>
>> WebSocketChannel channel = ...;<br>
>> channel.getReceiveSetter().set(new AbstractReceiveListener() {});<br>
>> channel.addCloseTask(new ChannelListener<WebSocketChannel>() {<br>
>> @Override<br>
>> public void handleEvent(WebSocketChannel channel) {<br>
>> ...<br>
>> }<br>
>> });<br>
>><br>
>> If receive setter is not set, then close task will not be called. In my<br>
>> case there was no intent to receive messages from the client and just push<br>
>> them from the server. Receive setter was not set => connection was not<br>
>> closed.<br>
>><br>
>> It seems obligatory to set receive setter all the time to make the thing<br>
>> work. Is it intended? While it is not a big deal really, I would imagine<br>
>> that Undertow should handle connection termination without explicit receive<br>
>> setter call made by the API client.<br>
>><br>
>><br>
>> On Tue, Oct 21, 2014 at 2:08 AM, Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>><br>
>> wrote:<br>
>>><br>
>>> WebsocketChannel.addCloseTask() should do what you are after (this is<br>
>>> actually provided by the base AbstractFramedChannel class).<br>
>>><br>
>>> Stuart<br>
>>><br>
>>> ----- Original Message -----<br>
>>> > From: "Vladimir Tsukur" <<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>><br>
>>> > To: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
>>> > Sent: Tuesday, 21 October, 2014 7:20:54 AM<br>
>>> > Subject: [undertow-dev] Handling termination of WebSocket connection<br>
>>> ><br>
>>> > Let's imagine user closed browser tab and thus terminated WebSocket<br>
>>> > connection. Is there any way to run a callback method on the<br>
>>> > server-side to<br>
>>> > handle this case?<br>
>>> ><br>
>>> > The requirement is to perform necessary cleanup actions when connection<br>
>>> > is<br>
>>> > closed, regardless of the type of disconnect (normal, forced<br>
>>> > termination,<br>
>>> > etc.).<br>
>>> ><br>
>>> > (Ideally using lower level API, and not JSR 356)<br>
>>> ><br>
>>> > --<br>
>>> > Vladimir Tsukur<br>
>>> > Software Architect, Design Engineer<br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > undertow-dev mailing list<br>
>>> > <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
>>> > <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Vladimir Tsukur<br>
>> Software Architect, Design Engineer<br>
><br>
><br>
><br>
><br>
> --<br>
> Vladimir Tsukur<br>
> Software Architect, Design Engineer<br>
><br>
> _______________________________________________<br>
> undertow-dev mailing list<br>
> <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Vladimir Tsukur<br>Software Architect, Design Engineer</div>
</div>