Re: WebSocket onClose/onError/onAbort is not being called
Hi Maxim, On Fri, May 1, 2020 at 2:22 PM Maxim Solodovnik wrote: > On Fri, 1 May 2020 at 18:15, Martin Grigorov wrote: > > > Hi Maxim, > > > > On Fri, May 1, 2020 at 1:31 PM Maxim Solodovnik > > wrote: > > > > > Hello Martin, > > > > > > WicketEndpoint#onError is being called > > > "*ERROR* 05-01 16:10:21.740 o.a.w.p.w.j.WicketEndpoint:100 > > > [EventExec-e2-t9] - An error occurred in web socket connection with id > : > > > 10" > > > > > > The problem WebSocketBehavior#onError is not being called > > > So my application doesn't get notified the connection has been closed > > > > > > > > > Then it must be somewhere in Wicket. > > Check that [2] is called. > > > > Yes it is called > > > > Then [3], then [4]. From here on it is Wicket Event propagation [5]. It > > > > [3] and [4] are not called > As you can see from the log branch at > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L299 > is in effect: > At https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L223 we check whether the connection is still opened or it is a ClosedMessage. ClosedMessage is broadcasted exactly for this reason: https://github.com/apache/wicket/commit/ffa34c6bfbd2ccd8340e23ff1601edd3e0e941d6 We should simplify this condition to allow ErrorMessage too. Maybe even AbortedMessage. For the erroneous kind of messages we can even remove the connection from the registry at the bottom of this method. Please play with it and suggest a change! Martin > DEBUG 05-01 16:10:21.741 o.a.w.p.w.a.AbstractWebSocketProcessor:299 > [EventExec-e2-t9] - Either there is no > > connection(org.apache.wicket.protocol.ws.javax.JavaxWebSocketConnection@43539f89 > ) > or it is closed. > > > > > > won't find your behavior if it is not enabled or any of if its component > > hierarchy is disabled/invisible. > > > > > > 2. > > > > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L202 > > 3. > > > > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L272 > > 4. * > > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java#L69 > > < > > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java#L69 > > >* > > 5. > > > > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketBehavior.java#L86 > > > > > > > :( > > > > > > On Fri, 1 May 2020 at 17:12, Martin Grigorov > > wrote: > > > > > > > Hi Maxim, > > > > > > > > If WicketEndpoint#onError() [1] is not called then probably there is > a > > > bug > > > > in Tomcat. > > > > I suggest you to post this question at Tomcat's users@. > > > > > > > > 1. > > > > > > > > > > > > > > https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java#L92 > > > > > > > > > > > > On Fri, May 1, 2020 at 12:21 PM Maxim Solodovnik < > solomax...@gmail.com > > > > > > > wrote: > > > > > > > > > Hello, > > > > > > > > > > I'm having weird situation: WebSocket connection is closed on page > > > > reload, > > > > > but none of my onClose/onError/onAbort handlers are being called > > > > > I have changed wicket version to latest SNAPSHOT and got some debug > > > logs: > > > > > > > > > > *ERROR* 05-01 16:10:21.740 o.a.w.p.w.j.WicketEndpoint:100 > > > > > [EventExec-e2-t9] - An error occurred in web socket connection with > > id > > > > > : 10 > > > > > java.io.IOException: java.io.IOException: Broken pipe > > > > > at > > > > > > > > > > > > > > > org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:315) > > > > > at > > > > > > > > > > > > > > > org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:258) > > > > > at > > > > > > > > > > > > > > > org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:612) > > > > > at > > > > > org.apache.tomcat.websocket.WsSession.doClose(WsSession.java:497
Feedback on Jira Issues
Hi all, I created two more tickets for potential improvements that showed up during profiling: - https://issues.apache.org/jira/projects/WICKET/issues/WICKET-6776 - https://issues.apache.org/jira/projects/WICKET/issues/WICKET-6780 Both are not urgent, because I was able to override the problematic behavior in my application, but it would be great if someone could give me some feedback so I can go ahead and create PRs if my suggestions make sense. Thanks and best regards, Thomas
Re: WebSocket onClose/onError/onAbort is not being called
Here are some more details on this issue In our code I'm using IWebSocketConnection.sendMessage(String) method The call is wrapped with try/catch to correctly handle any exception [1] The problem is hard to reproduce due to IOException should happen exactly at time of sendMessage do it's job (in original report author hammer the page with F5 until error will occur) As a result my try/catch doesn't play, I got "zombie" IWebSocketConnection in IWebSocketConnectionRegistry and incorrect application state due to I'm expecting to get disconnect from onClose/onError/onAbort of my WebSocketBehavior I see no other option than create periodic task to check for "zombies" in IWebSocketConnectionRegistry and restore application state Are there any other options? [1] https://github.com/apache/openmeetings/blob/master/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java#L76 On Fri, 1 May 2020 at 18:21, Maxim Solodovnik wrote: > > On Fri, 1 May 2020 at 18:15, Martin Grigorov wrote: > >> Hi Maxim, >> >> On Fri, May 1, 2020 at 1:31 PM Maxim Solodovnik >> wrote: >> >> > Hello Martin, >> > >> > WicketEndpoint#onError is being called >> > "*ERROR* 05-01 16:10:21.740 o.a.w.p.w.j.WicketEndpoint:100 >> > [EventExec-e2-t9] - An error occurred in web socket connection with id : >> > 10" >> > >> > The problem WebSocketBehavior#onError is not being called >> > So my application doesn't get notified the connection has been closed >> >> > >> >> Then it must be somewhere in Wicket. >> Check that [2] is called. >> > > Yes it is called > > >> Then [3], then [4]. From here on it is Wicket Event propagation [5]. It >> > > [3] and [4] are not called > As you can see from the log branch at > > https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L299 > is in effect: > > DEBUG 05-01 16:10:21.741 o.a.w.p.w.a.AbstractWebSocketProcessor:299 > [EventExec-e2-t9] - Either there is no > connection(org.apache.wicket.protocol.ws.javax.JavaxWebSocketConnection@43539f89) > or it is closed. > > > > >> won't find your behavior if it is not enabled or any of if its component >> hierarchy is disabled/invisible. >> >> >> 2. >> >> https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L202 >> 3. >> >> https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L272 >> 4. * >> https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java#L69 >> < >> https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java#L69 >> >* >> 5. >> >> https://github.com/apache/wicket/blob/d43c68c0126306021a12afbfe7876a36612fbbc3/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketBehavior.java#L86 >> >> >> > :( >> > >> > On Fri, 1 May 2020 at 17:12, Martin Grigorov >> wrote: >> > >> > > Hi Maxim, >> > > >> > > If WicketEndpoint#onError() [1] is not called then probably there is a >> > bug >> > > in Tomcat. >> > > I suggest you to post this question at Tomcat's users@. >> > > >> > > 1. >> > > >> > > >> > >> https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java#L92 >> > > >> > > >> > > On Fri, May 1, 2020 at 12:21 PM Maxim Solodovnik < >> solomax...@gmail.com> >> > > wrote: >> > > >> > > > Hello, >> > > > >> > > > I'm having weird situation: WebSocket connection is closed on page >> > > reload, >> > > > but none of my onClose/onError/onAbort handlers are being called >> > > > I have changed wicket version to latest SNAPSHOT and got some debug >> > logs: >> > > > >> > > > *ERROR* 05-01 16:10:21.740 o.a.w.p.w.j.WicketEndpoint:100 >> > > > [EventExec-e2-t9] - An error occurred in web socket connection with >> id >> > > > : 10 >> > > > java.io.IOException: java.io.IOException: Broken pipe >> > > > at >> > > > >> > > >> > >> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:315) >> > > > at >> > > > >> > > >> > >> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:258) >> > > > at >> > > > >> > > >> > >> org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:612)