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

Server Push does not initialize when recycling

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 6.5.2
    • Fix Version/s: 6.5.4
    • Component/s: General
    • Security Level: Jimmy
    • Labels:
    • Environment:

      Xubuntu 12.10
      Jetty 8.1.9
      Java version "1.7.0_21"
      OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-0ubuntu0.12.10.1)
      OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

      Description

      With DesktopRecycle, server push is not correctly started and does not work. The problem is that at enableServerPush0() of DesktopImpl, the Desktop already has _spush and therefore the initialization stage is omitted.

      This initialization stage calls the start() method of ServerPush, which in the case of PollingServerPush calls startClientPush(), which sends the start script to the client. The result is that the new/reloaded window does not receive the start script and never starts polling.

      I think the solution should be to split the sending of the start script from the initialization. At least in the case of PollingServerPush, the start script should always be sent.

        Activity

        Hide
        zhvihti zhvihti added a comment -

        The workaround for PollingServerPush is to manually send the start script to the client from DesktopRecycle, after getting the desktop to reuse:

        Clients.response("zk.clientpush", new AuScript(null, "zk.load('zk.cpsp');zk.afterLoad(function(){zk.cpsp.start('" + desktop.getId() + "');});"));
        Show
        zhvihti zhvihti added a comment - The workaround for PollingServerPush is to manually send the start script to the client from DesktopRecycle, after getting the desktop to reuse: Clients.response( "zk.clientpush" , new AuScript( null , "zk.load('zk.cpsp');zk.afterLoad(function(){zk.cpsp.start('" + desktop.getId() + "');});" ));
        Hide
        zhvihti zhvihti added a comment -

        Found a more robust solution: use an EventInterceptor, and in beforePostEvent(), on a ON_DESKTOP_RECYCLE event, do any client-side loading (not only starting Server Push, but we also show the busy mask if a backend operation is still ongoing).

        public class SingleDesktopRecycle implements DesktopRecycle {
        	@Override
        	public Desktop beforeService(Execution exec, String uri) {
        		// Get desktop from somewhere
        
        		// Add listener to send commands to client after an execution is created
        		desktop.addListener(new RestoreDesktopClientStatus(desktop));
        	}
        
        	public class RestoreDesktopClientStatus implements EventInterceptor {
        		private final Desktop desktop;
        		
        		public RestoreDesktopClientStatus(Desktop desktop) {
        			this.desktop = desktop;
        		}
        		
        		@Override
        		public Event beforeSendEvent(Event event) {
        			return event;
        		}
        		
        		@Override
        		public Event beforePostEvent(Event event) {
        			if (Events.ON_DESKTOP_RECYCLE.equals(event.getName())) {
        				// This is happening during response for desktop after we have an execution
        				
        				// Enable server push
        				Clients.response("zk.clientpush", new AuScript(null, "zk.load('zk.cpsp');zk.afterLoad(function(){zk.cpsp.start('"
        					+ desktop.getId() + "');});"));
        				
        				// Show busy mask
        				if (...) {
        					Clients.showBusy("Processing...");
        				}
        				
        				// Remove listener to not slow other events
        				desktop.removeListener(this);
        			}
        			return event;
        		}
        		
        		@Override
        		public Event beforeProcessEvent(Event event) {
        			return event;
        		}
        		
        		@Override
        		public void afterProcessEvent(Event event) {
        		}
        	}
        }
        
        Show
        zhvihti zhvihti added a comment - Found a more robust solution: use an EventInterceptor, and in beforePostEvent(), on a ON_DESKTOP_RECYCLE event, do any client-side loading (not only starting Server Push, but we also show the busy mask if a backend operation is still ongoing). public class SingleDesktopRecycle implements DesktopRecycle { @Override public Desktop beforeService(Execution exec, String uri) { // Get desktop from somewhere // Add listener to send commands to client after an execution is created desktop.addListener( new RestoreDesktopClientStatus(desktop)); } public class RestoreDesktopClientStatus implements EventInterceptor { private final Desktop desktop; public RestoreDesktopClientStatus(Desktop desktop) { this .desktop = desktop; } @Override public Event beforeSendEvent(Event event) { return event; } @Override public Event beforePostEvent(Event event) { if (Events.ON_DESKTOP_RECYCLE.equals(event.getName())) { // This is happening during response for desktop after we have an execution // Enable server push Clients.response( "zk.clientpush" , new AuScript( null , "zk.load('zk.cpsp');zk.afterLoad(function(){zk.cpsp.start('" + desktop.getId() + "');});" )); // Show busy mask if (...) { Clients.showBusy( "Processing..." ); } // Remove listener to not slow other events desktop.removeListener( this ); } return event; } @Override public Event beforeProcessEvent(Event event) { return event; } @Override public void afterProcessEvent(Event event) { } } }
        Hide
        cor3000 cor3000 added a comment -

        issue also happens for CometServerPush in combination with DesktopRecycle

        Show
        cor3000 cor3000 added a comment - issue also happens for CometServerPush in combination with DesktopRecycle
        Hide
        vincentjian vincentjian added a comment -

        Fixed since 2013/7/15

        Show
        vincentjian vincentjian added a comment - Fixed since 2013/7/15

          People

          • Assignee:
            cor3000 cor3000
            Reporter:
            zhvihti zhvihti
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: