Another Push Problem

I am very new to Vaadin, but am really impressed so far. However, I really need Push to work, and I think I have read every thread on internet about it and every post I can find (including everything on this awesome page: https://vaadin.com/book/vaadin7/-/page/advanced.push.html) and it still has no effect.

I believe the code is correct: I use Pushmode.MANUAL and push when I want to update. I also tried Pushmode automatic. I see the code being hit properly and running correctly… just no change in the UI.

I think it has something to do with server setup. The last two lines of the console output when the server starts are:
Mar 10, 2015 6:59:12 PM com.vaadin.server.communication.PushHandler connectionLost
SEVERE: Could not get UI. This should never happen, except when reloading in Firefox - see http://dev.vaadin.com/ticket/14251.

The ticket references starting up in Firefox, but I am running internally from Eclipse.

So my questions are:
(1) How do I go about debugging this? and
(2) In the Swing version of this app, there are simple refresh() and update() methods that force the interface to reload. Is there anything like this in Vaadin components? I don’t see anything comparable.

I am fine with the latter low-tech solution. In fact, I like having that control.

Thanks for all your help.

Hi,

Can you please show us your code, secondly which server are you using?
Also, just check if your browser supports push, though vaadin framework fallbacks to Streaming.

Can you please try it out on modern browsers and report back what happens

Thanks,
Krishna.

I am deploying to Tomcat 8.0.18 and tested using the current Firefox (36.0.1). It doesn’t work fo rme.

After further thought, I am thinking that push might not be the best option for me. I won’t have any control of the client browser vendor or version and need to make sure this works all the time.

Is there a non-push option to force reload of the browser screen contents? If not, I will start posting code sections.

Thanks.

Did you try
poll
?

Definitely. That was my first (and much preferred) choice. The poller is definitely working.

The poll listener does prints out a console message and calls a method:
addPollListener(new UIEvents.PollListener() {
@Override
public void poll(UIEvents.PollEvent event) {
System.out.println(“Polling”);
mainview.update();
}
});

The method (mainview.update()) gets an auto-incremented value of a counter and sets a label value:
public void update()
{
String value = interfaces.getCounter();
counterValue.setValue(value);
}

I can see the counter incrementing and the poller working, and if I manually refresh the page, I see it update correctly, but it doesn’t refresh automatically.

I think you have ensure thread-safety in the UI, updating it inside a UI.access().

Take a look at Progress bar for some guideance:
https://vaadin.com/book/-/page/components.progressbar.html

Good suggestion!

My update method now looks like this:
public void update()
{
// Update the UI thread-safely
getUI().getCurrent().access(new Runnable() {
@Override
public void run() {
String value = interfaces.getCounter();
counterValue.setValue(value);
System.err.println(“updating the label safely”);
}
});
}

but it still has no effect. I see that it is in the method at the correct time, but no update on the UI unless I manually refresh.

But we are making progess because when I manually refresh, I now see this message in the console;
Mar 11, 2015 11:09:42 AM com.vaadin.server.communication.PushHandler connectionLost
INFO: No UI was found based on data in the request, but a slower lookup based on the AtmosphereResource succeeded. See http://dev.vaadin.com/ticket/14251 for more details.

That link to the ticket times out. :confused:

So that is now two places where I get connection lost messages.

Thanks for all your guidance.

Can you please build a stripped down version of your source and share it with us we can check and tell you where exactly is the problem

I have stripped this down to two small files that i have attached. I just created a new Vaadin 7 project and dropped them in. It shows the same behavior as the previous larger project… I can see the counter getting updated but the udpate only occurs when I manually refresh the page in the browser.

I hope I didn’t leave out anything important in this project… the original project has been through a thousand changes in the past couple days trying to resolve this.

I am positive that the solution is super simple, and greatly appreciate you all helping me out.

Thanks.
18534.java (2.06 KB)
18535.java (1.67 KB)

Have I asked the smartest, most confusing question of all time? haha

Can no one duplicate my issue with these two small files?

Was busy with my work and I just overlooked this post some how, good that you pinged… Can you please share the version of Vaadin, So that I will look in to it right away

No problem. You guys are doing me a favor. I am not in any big hurry, and I assumed it just got lost over the weekend.

I don’t have the version in front of me, but I just downloaded it last week, so I am assuming it is the current 7.4.1 version.

Thanks for your help.

Hi Neil,

I modified your source code and attached with this mail.

There are few things to note -

  1. You have created a created a variable of type counterValue twice once as a local variable and twice a class level variable and your are adding the local variable to the layout
  2. PollListener is used for logging purpose. Not for update of data - Please check
    here
  3. Once you are done with polling make sure that you stop it.

Hope this helps you

Thanks,
Krishna.
18701.java (2.43 KB)
18702.java (1.29 KB)

Thanks. I just skimmed this, but I am in the middle of work myself, and will look at this in detail later.

You have definitely rearranged what I am trying to accomplish, so I don’t know how much of that I can use.

I am trying to build a dashboard. This isn’t something like a progress bar where I poll for a while and then stop. It has to be architected mostly like I had it… the main UI has to have a listener which periodically can poll some business logic for updates so I can update the dashboard.

However, I am definitely going to try the markAsDirty method tomorrow morning to see if that has any effect.

Thanks again for your help.

I had a minute to look at this in greater detail. To answer your points:

  1. You have created a created a variable of type counterValue twice once as a local variable and twice a class level variable and your are adding the local variable to the layout… Answer: Ooops… I fixed that, but it had no effect
  2. PollListener is used for logging purpose. Not for update of data - Please check here … Answer: The pollListener’s entire purpose is to call the business logic method to get the values to update the dashboard. It is not for logging.
  3. Once you are done with polling make sure that you stop it… Answer: This is a dashboard, so I don’t want to stop it.

I also add the markAsDirty method, but that didn’t help either.

Is there something wrong with what I am trying to accomplish architecturally that prevents Vaadin from updating as I need?

I just gave an example as logging, may be because of late night post I misquoted the context. Anyway, setPollListener didn’t work for me like the way you have used.

BTW, why can’t you create a daemon that auto updates the UI, when Poll happens the ui is refreshed… This should work

Interesting. So it should work. But
DOES
it?

If you take those two files and drop them in a new eclipse project, does it work properly for you? In other words, is there something bizarre in my setup that is preventing the browser from updating?

I would be extremely happy if this was just some environmental or setup issue.

Just closing this thread in case someone searches for something like this later.

I wound up downloading the Eclipse GWT plugin and redoing my app template in GWT. The polling/refresh capability worked first time I deployed it. Counting the online tutorial I watched (since I had never used GWT before), I had this working in GWT in about 30 minutes.

I suppose Vaadin just wasn’t the right choice for me. Good luck to you all and maybe I will try this project again in a few years.