Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4522

websockets not working on WildFly after ZK-4429

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 8.6.4
    • Fix Version/s: 9.0.1
    • Component/s: ZK Client Engine
    • Labels:
    • Environment:

      Fails on WildFly Full 18.0.1.Final
      Works with Jetty / Tomcat / Glassfish

    • gh.sprint.customfield.default.name:
      ZK 9.0.1 S1

      Description

      Steps to Reproduce

      enable WebSocket in zk.xml

      trigger an AU

      <zk>
          <button onClick="Clients.log(event.toString())" label="test event"/>
      </zk>
      

      Current Result

      server error in WildFly Full 18.0.1.Final

      04:08:30,678 WARN  [org.zkoss.zkmax.au.websocket.WebSocketEndPoint] (default task-2) SERVER ERROR: java.lang.IllegalStateException: ZK Session cannot be null!
      	at deployment.zktest-9.0.1-SNAPSHOT.war//org.zkoss.zk.ui.http.ZKWebSocket.initZkDesktop(ZKWebSocket.java:80)
      	at deployment.zktest-9.0.1-SNAPSHOT.war//org.zkoss.zkmax.au.websocket.WebSocketEndPoint.onOpen(WebSocketEndPoint.java:93)
      	at [email protected]//io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:129)
      	at [email protected]//io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:165)
      	at [email protected]//io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:385)
      	at [email protected]//io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:232)
      	at [email protected]//io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1279)
      	at [email protected]//io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1563)
      	at [email protected]//io.undertow.server.Connectors.terminateResponse(Connectors.java:159)
      	at [email protected]//io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:197)
      	at [email protected]//io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:195)
      	at [email protected]//io.undertow.conduits.HeadStreamSinkConduit.exitFlush(HeadStreamSinkConduit.java:192)
      	at [email protected]//io.undertow.conduits.HeadStreamSinkConduit.flush(HeadStreamSinkConduit.java:133)
      	at [email protected]//org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
      	at [email protected]//io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119)
      	at [email protected]//org.xnio.channels.Channels.flushBlocking(Channels.java:63)
      	at [email protected]//io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:618)
      	at [email protected]27.Final//io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:528)
      	at [email protected]//io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:617)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:328)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
      	at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      	at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      	at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
      	at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
      	at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      	at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      
      04:08:30,692 ERROR [io.undertow.websockets.jsr.request] (default task-2) UT026001: Unable to instantiate endpoint: java.lang.NullPointerException
      	at deployment.zktest-9.0.1-SNAPSHOT.war//org.zkoss.zkmax.au.websocket.WebSocketEndPoint.sendText(WebSocketEndPoint.java:297)
      	at deployment.zktest-9.0.1-SNAPSHOT.war//org.zkoss.zkmax.au.websocket.WSAuWriter.close(WSAuWriter.java:68)
      	at deployment.zktest-9.0.1-SNAPSHOT.war//org.zkoss.zkmax.au.websocket.WebSocketEndPoint.onError(WebSocketEndPoint.java:163)
      	at [email protected]//io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:131)
      	at [email protected]//io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:165)
      	at [email protected]//io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:385)
      	at [email protected]//io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:232)
      	at [email protected]//io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1279)
      	at [email protected]//io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1563)
      	at [email protected]//io.undertow.server.Connectors.terminateResponse(Connectors.java:159)
      	at [email protected]//io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:197)
      	at [email protected]//io.undertow.server.protocol.http.HttpTransferEncoding$3.handleEvent(HttpTransferEncoding.java:195)
      	at [email protected]//io.undertow.conduits.HeadStreamSinkConduit.exitFlush(HeadStreamSinkConduit.java:192)
      	at [email protected]//io.undertow.conduits.HeadStreamSinkConduit.flush(HeadStreamSinkConduit.java:133)
      	at [email protected]//org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
      	at [email protected]//io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119)
      	at [email protected]//org.xnio.channels.Channels.flushBlocking(Channels.java:63)
      	at [email protected]//io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:618)
      	at [email protected]//io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:528)
      	at [email protected]//io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:617)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:328)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
      	at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      	at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      	at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
      	at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
      	at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
      	at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      	at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      

      Expected Result

      working WS connection

      Debug Information

      https://github.com/zkoss/zkcml/blob/v8.6.4/zkmax/src/org/zkoss/zkmax/au/websocket/WebSocketFilter.java#L68

      In Undertow this would be triggered twice.
      ZK cannot get the ZK Session by tempSessionKey since it is different.

      Workaround

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rudyhuang rudyhuang
              Reporter:
              rudyhuang rudyhuang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h