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

Can't establish a WebSocket connection in Jetty 11

    XMLWordPrintable

    Details

      Description

      Steps to Reproduce

      Use 9.6.0-jakarta FL in Jetty 11, and open WebSocket

      <!-- zk.xml -->
      <listener>
      	<listener-class>org.zkoss.zkmax.au.websocket.WebSocketWebAppInit</listener-class>
      </listener>
      
      <!-- test.zul -->
      <zk>
          <button onClick="Clients.log(event.toString())" label="test event"/>
      </zk>
      

      Current Result

      A "ZK Session cannot be null!" exception and use failsafe ajax

      Expected Result

      Established a WebSocket connection

      Debug Information

      https://github.com/zkoss/zk/blob/v9.5.1.3/zk/src/org/zkoss/zk/ui/http/ZKWebSocket.java#L71
      In Session.getRequestParameterMap, connection_uuid was missing.

      There is a fake request in org.zkoss.zkmax.au.websocket.WebSocketFilter to add connection_uuid in requestParameterMap, but Jetty 11 won't use it.

      Instead, org.eclipse.jetty.websocket.core.internal.Negotiated parses the query string (ws://localhost:8080/zkwm?dtid=z_83A8Jz9FIG5uoAWPYdaPzQ) as a newly created parameter map.

      https://github.com/eclipse/jetty.project/blob/jetty-9.4.42.v20210604/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java#L285
      https://github.com/eclipse/jetty.project/blob/jetty-11.0.4/jetty-websocket/websocket-jakarta-common/src/main/java/org/eclipse/jetty/websocket/jakarta/common/JakartaWebSocketSession.java#L499

      The "Solution Using Request Parameters" workaround from https://stackoverflow.com/a/30180015 is not working anymore.

      Workaround


        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Time Spent - 4 hours Remaining Estimate - 4 hours
                  4h
                  Logged:
                  Time Spent - 4 hours Remaining Estimate - 4 hours
                  4h