In ZK 8.5, there is a new session, where a WebSocket-based update engine is introduced to handle requests if the browser is supported.

The advantage of WebSocket (over AJAX), is once the connection has been established, all future messages are passed over the socket rather than new HTTP request/response calls. The ping and pong messages will be smooth and also save traffic!

We support not only WebSocket-based Update Engine, but also a WebSocket-based server push. This reduces the count of http connections when there is a huge amount of updates.

WebSocket Demo

In the first clip, we can see when the ajax-based ZK update engine is on, numerous requests will be established. While in the second clip, with websocket based ZK update engine, there is only one connection established; even if we enable server push, less HTTP overhead.

Required Configuration


  • ZK: 8.5.0.FL.20170725-Eval or later
  • Browser: Internet Explorer 10+, Edge, Firefox, Chrome, Safari, iOS Safari, Android Browser, Opera


<!-- required -->

<!-- optional -->
    • Line 2 to 4: It is required to add a configuration to enable the WebSocket connection.
    • Line 6 to 9: Map the url pattern for WebSocket connection; if this library property is not configured, /zkwm will be used by default.

Be noted that WebSocketServerPush will be the selected server push class if the WebSocket connection is on, even though other server push class is configured in zk.xml.


The whole demo project can be found on Github project.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

5 Responses to “ZK 8.5 Preview: Built in WebSocket Communication is Now Provided”

  1. Costas Yiannoulis says:

    I can’t wait to see this feature!

  2. Vincent Lee says:

    Is there any thing special required for the app server to support this?

  3. Hawk says:

    @Vincent Lee
    websocket API (JSR 356) is a part of Java EE 7 standard. ( So all Java EE 7–compliant application servers will have an implementation of the WebSocket protocol that adheres to the JSR 356 standard e.g. Tomcat 7 (refer to

  4. fenrir says:

    have nullpoint in WebSocketWebAppInit:

    at org.zkoss.zk.ui.util.Configuration.invokeWebAppInits(
    at org.zkoss.zk.ui.impl.AbstractWebApp.init(
    at org.zkoss.zk.ui.http.SimpleWebApp.init(
    at org.zkoss.zk.ui.http.WebManager.(
    at org.zkoss.zk.ui.http.HttpSessionListener23.contextInitialized(
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(
    at org.eclipse.jetty.webapp.WebAppContext.startContext(
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(
    at org.eclipse.jetty.webapp.WebAppContext.doStart(
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(
    at org.eclipse.jetty.server.Server.doStart(
    at org.mortbay.jetty.plugin.JettyServer.doStart(
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
    at org.apache.maven.DefaultMaven.doExecute(
    at org.apache.maven.DefaultMaven.doExecute(
    at org.apache.maven.DefaultMaven.execute(
    at org.apache.maven.cli.MavenCli.execute(
    at org.apache.maven.cli.MavenCli.doMain(
    at org.apache.maven.cli.MavenCli.main(
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.base/java.lang.reflect.Method.invoke(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(
    at org.codehaus.classworlds.Launcher.main(

  5. Robert Wenzel says:

    @fenrir: it looks like your jetty configuration is missing the websocket module

    However this comment section of our blog is not a good place to start such a discussion/debugging thread.
    Please either refer to our support or ask your question in our forum

    Also please never forget to mention your ZK version and in this case Jetty version, and if possible provide all the configuration required to reproduce the error message.

Leave a Reply