[ 
https://issues.apache.org/jira/browse/KNOX-1997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16916908#comment-16916908
 ] 

Kevin Risden commented on KNOX-1997:
------------------------------------

[~rajatg] - thanks for filing. Based on your knox-user email, added you as a 
contributor and assigned this to you since you said you are working on a patch. 
Let us know if that is not the case. Looking forward to the contribution.

> For websocket connections, seeing java.lang.NullPointerException when a data 
> frame arrives on websocket while connection is still being setup
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: KNOX-1997
>                 URL: https://issues.apache.org/jira/browse/KNOX-1997
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.0.0, 1.1.0, 1.2.0, 1.3.0
>         Environment: HDP 3.1.0
>            Reporter: Rajat Goel
>            Assignee: Rajat Goel
>            Priority: Major
>             Fix For: 1.4.0
>
>         Attachments: gateway.log_26Aug.gz
>
>
> I am seeing following exception in Knox gateway logs:
> {code:java}
> // Some comments here
> public String getFoo()
> {
>     return foo;
> }
> {code}
> 2019-08-23 12:43:46,347 WARN websockets.ProxyInboundClient 
> (AbstractEventDriver.java:unhandled(251)) - Unhandled Error (closing 
> connection)_
> _java.lang.NullPointerException_
> _at 
> org.apache.knox.gateway.websockets.ProxyWebSocketAdapter$3.onMessageText(ProxyWebSocketAdapter.java:260)_
> _at 
> org.apache.knox.gateway.websockets.ProxyInboundClient$2.onMessage(ProxyInboundClient.java:87)_
> _at 
> org.apache.knox.gateway.websockets.ProxyInboundClient$2.onMessage(ProxyInboundClient.java:78)_
> _at 
> org.eclipse.jetty.websocket.jsr356.messages.TextWholeMessage.messageComplete(TextWholeMessage.java:56)_
> _at 
> org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver.onTextFrame(JsrEndpointEventDriver.java:218)_
> _at 
> org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:162)_
> _at 
> org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:476)_
> _at 
> org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:220)_
> _at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:219)_
> _at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:244)_
> _at 
> org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onConnectionStateChange(AbstractWebSocketConnection.java:337)_
> _at 
> org.eclipse.jetty.websocket.common.io.IOState.notifyStateListeners(IOState.java:184)_
> _at org.eclipse.jetty.websocket.common.io.IOState.onOpened(IOState.java:447)_
> _at 
> org.eclipse.jetty.websocket.common.WebSocketSession.open(WebSocketSession.java:619)_
> _at 
> org.eclipse.jetty.websocket.common.WebSocketSession.onOpened(WebSocketSession.java:544)_
> _at 
> org.eclipse.jetty.io.AbstractConnection.onOpened(AbstractConnection.java:209)_
> _at 
> org.eclipse.jetty.io.AbstractConnection.onOpen(AbstractConnection.java:202)_
> _at 
> org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onOpen(AbstractWebSocketConnection.java:446)_
> _at org.eclipse.jetty.io.AbstractEndPoint.upgrade(AbstractEndPoint.java:440)_
> _at 
> org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.upgrade(WebSocketUpgradeRequest.java:624)_
> _at 
> org.eclipse.jetty.client.http.HttpChannelOverHTTP.exchangeTerminating(HttpChannelOverHTTP.java:118)_
> _at 
> org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:462)_
> _at 
> org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:416)_
>  
> I added more debug logs in Knox to analyze the issue and observed following 
> was happening:
>  * Knox generates proper URL for backend websocket connection
> _2019-08-23 12:43:46,068 DEBUG gateway.websockets 
> (GatewayWebsocketHandler.java:createWebSocket(148)) - Message: Rajat .. 
> backednUrl = 
> ws://[rafd001-mst-01.cloud.in.guavus.com:11011/_sock/411/anq2kfzp/websocket|http://rafd001-mst-01.cloud.in.guavus.com:11011/_sock/411/anq2kfzp/websocket]_
>  * Websocket upgrade successful at HTTP protocol layer. Knox starts setting 
> up its session management internal data structures for this connection
> _2019-08-23 12:43:46,313 DEBUG client.HttpReceiver 
> (HttpReceiver.java:responseSuccess(403)) - Response success 
> HttpResponse[HTTP/1.1 101 Switching Protocols]@708f1c60_
> _2019-08-23 12:43:46,324 DEBUG common.WebSocketSession 
> (WebSocketSession.java:doStart(248)) - starting - 
> WebSocketSession[websocket=JsrEndpointEventDriver[org.apache.knox.gateway.websockets.ProxyInboundClient],behavior=CLIENT,connection=WebSocketClientConnection@1528d316::SocketChannelEndPoint@10d45033
>  
> {[rafd001-mst-01.cloud.in.guavus.com/192.168.133.69:11011|http://rafd001-mst-01.cloud.in.guavus.com/192.168.133.69:11011]<->/[192.168.133.69:50702|http://192.168.133.69:50702/],OPEN,fill=-,flush=-,to=23/300000}
>  \{io=0/0,kio=0,kro=1} > 
> r:[rafd001-mst-01.cloud.in.guavus.com/192.168.133.69:11011,closed=false)=|http://rafd001-mst-01.cloud.in.guavus.com/192.168.133.69:11011,closed=false)=]>HttpChannelOverHTTP@26de2594(exchange=HttpExchange@7e8b6268
>  req=TERMINATED/null@null 
> res=TERMINATED/null@null)[send=HttpSenderOverHTTP@73b692d4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@4e3bb764\{s=START}],recv=HttpReceiverOverHTTP@7d5a172b(rsp=IDLE,failure=null)[HttpParser\{s=START,0
>  
> of1}]],remote=null,incoming=JsrEndpointEventDriver[org.apache.knox.gateway.websockets.ProxyInboundClient],outgoing=ExtensionStack[queueSize=0,extensions=[],incoming=org.eclipse.jetty.websocket.jsr356.JsrSession,outgoing=org.eclipse.jetty.websocket.client.io.WebSocketClientConnection]]_
>  * A data frame arrives on the connection from CDAP backend and Knox starts 
> processing it in a separate thread but internal data structures have not yet 
> been established fully:
> _2019-08-23 12:43:46,346 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:onMessageText(257)) - Message: Rajat .. In 
> onMessageText .. remote is nulll_
> _2019-08-23 12:43:46,347 WARN websockets.ProxyInboundClient 
> (AbstractEventDriver.java:unhandled(251)) - Unhandled Error (closing 
> connection)_
> _java.lang.NullPointerException_
> _at 
> org.apache.knox.gateway.websockets.ProxyWebSocketAdapter$3.onMessageText(ProxyWebSocketAdapter.java:260)_
> _at 
> org.apache.knox.gateway.websockets.ProxyInboundClient$2.onMessage(ProxyInboundClient.java:87)_
> _at 
> org.apache.knox.gateway.websockets.ProxyInboundClient$2.onMessage(ProxyInboundClient.java:78)_
>  * As a result of this exception, Knox starts closing this connection as well 
> as connection with front end.
> _2019-08-23 12:43:46,347 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:onError(246)) - Message: Rajat .. inside onError_
> _2019-08-23 12:43:46,348 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:cleanupOnError(183)) - Message: Rajat .. inside 
> cleanupOnError_
> _2019-08-23 12:43:46,348 ERROR gateway.websockets 
> (ProxyWebSocketAdapter.java:cleanupOnError(185)) - Error: 
> java.lang.NullPointerException_
> _2019-08-23 12:43:46,349 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:closeQuietly(294)) - Message: Rajat .. in 
> closeQuietly_
>  * Internal data structures are now setup in the other thread
> _2019-08-23 12:43:46,356 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:onWebSocketConnect(113)) - Message: Rajat ... 
> frontEndSession = 
> WebSocketSession[websocket=JettyListenerEventDriver[org.apache.knox.gateway.websockets.ProxyWebSocketAdapter],behavior=SERVER,connection=WebSocketServerConnection@151585ba::DecryptedEndPoint@4463419a
>  
> {/[192.168.110.254:61755|http://192.168.110.254:61755/]<>/[192.168.133.69:8443|http://192.168.133.69:8443/],OPEN,fill=,flush=,to=423/300000},remote=WebSocketRemoteEndpoint@66632a26[batching=true],incoming=JettyListenerEventDriver[org.apache.knox.gateway.websockets.ProxyWebSocketAdapter],outgoing=ExtensionStack[queueSize=0,extensions=[permessage-deflate],incoming=org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension,outgoing=org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension]]_
> _2019-08-23 12:43:46,358 DEBUG gateway.websockets 
> (ProxyWebSocketAdapter.java:onWebSocketConnect(119)) - Message: Rajat 
> ...front remote = WebSocketRemoteEndpoint@66632a26[batching=true]_
>  * Fronted UI sees connection closed and send a new connection request.
> Looks like there is a race condition/improper synchronization between two 
> Knox threads: one thread opening a websocket connection, setting up the 
> connection session and the other thread processing a message/data packet sent 
> by UI service backend.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to