buttonClick event slow

Hi,

I have a following problem:

In the application opening page, when I click a button for the first time, the event takes ~30 seconds to reach buttonClick-function. During this waiting time loading indicator appears to the upper right corner and goes from white to yellow to red. After this, all click events are passed immediately.

If application is left idle for some time and then any button is clicked again, the same effect occures. After ~30 seconds of loading the event passes and following events are passed again immediately. I assume this behaviour is due timeout or such. If I use a different browser at the same time, the same issue occures on both browsers and it occures everytime a new session is created.

Now, this happens only when the application is deployed to hosted Jelastic site (Tomcat 7.0.53). When I run the application on local workstation (Eclipse + Tomcat 7.0) it works perfectly. I’m using Vaadin 7.3.0.

Does anyone have (had) similar problems and more important, any solutions to this problem? Is Jelastic or Tomcat somehow problematic with Vaadin?
I’m happy to hear any and all suggestions.

Br,
Juho Piirainen

deploy my application to hosted enviroment (Jelastic) with Tomcat 7.0.53

Are you using a trial account on JElastic? They improve their cluster efficiency by “hibernating” applications that haven’t used recently, but at least according to
http://stackoverflow.com/questions/24233759/how-can-i-get-jelastic-to-sleep
that feature should be on by default only for trial accounts.

That’s strange. I don’t use Jelastic myself, so wouldn’t know if it has any issues… The best way to investigate the issue would be to check what part is taking a long time, server or client side. In your case you can only check the client side, but at least you can narrow down the issue. You can use e.g. the Chrome Inspector to track and record network activity; if it is the clent that is slow, then the server request should be quick. If it is the server, the request should be slow. Based on the spinner, I would take a guess at the server side being the culprit.

If the issue is indeed with the server side, and it works for you locally (“hey, it works for me!”), there isn’t really any other choice than to contact Jelastic and ask them to investigate.

Just thought of something: you can add log messages to check the timing by overriding the default servlets’ service method, or by adding a servlet filter to your app. That should tell you if it is the infrastructure or your app that is slow.

Thanks for the quick replys.

This is strange indeed. I contacted Jelastic providers customer service and they said that trial and payed versions should not have any differences that would cause this. Even more strange, first page of the application loads ok. The problem occures when first event is fired on login/registed view (event does not reach buttonClick-method). After the first event reaches Vaadin framework the rest of the events works fine, until short idle. After idle the first event is slow again.

I tested with Vaadin example and the buttonClick worked in the same Jelasctic enviroment correctly. So, I assume the problem is actually in the application code. I need to drop components one-by-one until I reach a working war-package.

It’s just strange that the application works fine on local machine, but not on Jelastic.

Ok, I got a handle of this. It seems to be related to server push and @Push annotation.

I created a Vaadin 7 Eclipse example project (with Button and a label “Thank you for clicking” which appear after button click. I created war-file and deployed. Click works fine. Then a added @Push annotation, created a war-file, deployed and TADAA! button event was slow. I removed the @Push again, created war, deployed and click event was immediate again. I did the same for my larger application with same results.

This seems to be a trouble with Vaadin server push and Jelastic enviroment.
Can anyone @Vaadin confirm or decline this bug? Or is there samething I don’t define correctly with @push annotation?
I include the code TestprojectwithpushUI-class. I have only added the @push annotation.

package com.example.testprojectwithpush;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("testprojectwithpush")
@Push
public class TestprojectwithpushUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = TestprojectwithpushUI.class)
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                layout.addComponent(new Label("Thank you for clicking"));
            }
        });
        layout.addComponent(button);
    }

}

This is probably caused by a not-very-push-compatible proxy Jelastic is using. You might like to try @Push(transport=Transport.LONG_POLLING) as it should play along with proxies a bit better at least. If that does not work, I’m afraid there’s not much to be done, except using plain polling instead of push.

Hi,

@Push(transport=Transport.LONG_POLLING) This solved most of the problem. Events still have a really short delay, but it’s under a second, so it’s acceptable.

Thanks to everyone!