Sessionguard not working for me

Dear all,

after using Sessionguard in several projects I realized it never worked for me. I read the thread regarding Sessionguard here in the forum where some guy had the same issue. His problem was, that the layout containing the Sessionguard was removed later in the code by calling some setContent() on the window. I had the same issue, but fixing that did not help me bring it to work.

Here is my code for initialization, the method is called once, when I log in. I hope it is okay to remove the session guard later and re-adding it. But at the test stage, it was only added once. It made no difference if I added it to the layout or the window.

private void initLayout() {
        System.out.println("Called only once :)");
        removeAllComponents();
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeFull();
        initMenuBar(layout);
        initContent(layout);

        SessionGuard sessionGuard = new SessionGuard();        
//        sessionGuard.setKeepalive(true);
        sessionGuard.setTimeoutWarningPeriod(2);
        
        // TODO session guard not working.. why?
        
        setContent(layout);
        addComponent(sessionGuard);
    }

session timeout is 3 minutes
just like in the demo, any idea what I’m doing wrong? :slight_smile:

Thank you so much

session guard is not ported to final vaadin 7 version, vaadin’s built-in heart-beat functionality does the job