<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 &quot;close&quot; 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">&lt;<a href="mailto:cody.lerum@gmail.com" target="_blank">cody.lerum@gmail.com</a>&gt;</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&#39;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&#39;t upgraded yet to verify.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Oct 21, 2014 at 9:07 AM, Vladimir Tsukur &lt;<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>&gt; wrote:<br>
&gt; One more observation - in case network connection is completely lost in<br>
&gt; between client and server, &quot;close&quot; notifiers are not invoked at all (tried<br>
&gt; by shutting down network connection on the client machine keeping browser<br>
&gt; tab opened). In this case there is no opportunity for a client to send a<br>
&gt; close frame to the server. Is it a bug then? Using Undertow 1.2.0.Beta1<br>
&gt;<br>
&gt; On Tue, Oct 21, 2014 at 4:10 PM, Vladimir Tsukur &lt;<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Thanks Stuart,<br>
&gt;&gt;<br>
&gt;&gt; Did not see this method in 1.0.x since it was added at a later release -<br>
&gt;&gt; tried with latest version and it works well.<br>
&gt;&gt;<br>
&gt;&gt; However, I figured out that connection termination works well iif receive<br>
&gt;&gt; setter is set:<br>
&gt;&gt;<br>
&gt;&gt;     WebSocketChannel channel = ...;<br>
&gt;&gt;     channel.getReceiveSetter().set(new AbstractReceiveListener() {});<br>
&gt;&gt;     channel.addCloseTask(new ChannelListener&lt;WebSocketChannel&gt;() {<br>
&gt;&gt;         @Override<br>
&gt;&gt;         public void handleEvent(WebSocketChannel channel) {<br>
&gt;&gt;             ...<br>
&gt;&gt;         }<br>
&gt;&gt;     });<br>
&gt;&gt;<br>
&gt;&gt; If receive setter is not set, then close task will not be called. In my<br>
&gt;&gt; case there was no intent to receive messages from the client and just push<br>
&gt;&gt; them from the server. Receive setter was not set =&gt; connection was not<br>
&gt;&gt; closed.<br>
&gt;&gt;<br>
&gt;&gt; It seems obligatory to set receive setter all the time to make the thing<br>
&gt;&gt; work. Is it intended? While it is not a big deal really, I would imagine<br>
&gt;&gt; that Undertow should handle connection termination without explicit receive<br>
&gt;&gt; setter call made by the API client.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Oct 21, 2014 at 2:08 AM, Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; WebsocketChannel.addCloseTask() should do what you are after (this is<br>
&gt;&gt;&gt; actually provided by the base AbstractFramedChannel class).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Stuart<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ----- Original Message -----<br>
&gt;&gt;&gt; &gt; From: &quot;Vladimir Tsukur&quot; &lt;<a href="mailto:flushdia@gmail.com">flushdia@gmail.com</a>&gt;<br>
&gt;&gt;&gt; &gt; To: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; &gt; Sent: Tuesday, 21 October, 2014 7:20:54 AM<br>
&gt;&gt;&gt; &gt; Subject: [undertow-dev] Handling termination of WebSocket connection<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Let&#39;s imagine user closed browser tab and thus terminated WebSocket<br>
&gt;&gt;&gt; &gt; connection. Is there any way to run a callback method on the<br>
&gt;&gt;&gt; &gt; server-side to<br>
&gt;&gt;&gt; &gt; handle this case?<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; The requirement is to perform necessary cleanup actions when connection<br>
&gt;&gt;&gt; &gt; is<br>
&gt;&gt;&gt; &gt; closed, regardless of the type of disconnect (normal, forced<br>
&gt;&gt;&gt; &gt; termination,<br>
&gt;&gt;&gt; &gt; etc.).<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; (Ideally using lower level API, and not JSR 356)<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; --<br>
&gt;&gt;&gt; &gt; Vladimir Tsukur<br>
&gt;&gt;&gt; &gt; Software Architect, Design Engineer<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt;&gt; &gt; undertow-dev mailing list<br>
&gt;&gt;&gt; &gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Vladimir Tsukur<br>
&gt;&gt; Software Architect, Design Engineer<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Vladimir Tsukur<br>
&gt; Software Architect, Design Engineer<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; undertow-dev mailing list<br>
&gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; <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>