i want to update the UI every 10 seconds.
What i did was:
<init-param>
<param-name>pushmode</param-name>
<param-value>automatic</param-value>
</init-param>
<async-supported>true</async-supported>
Add this to my web.xml.
Added the @Push annotation to my UI class.
Now im trying to update the UI from another “View”-class.
/*
/ ...
*/
public MyClass(Navigator navigator) {
test();
}
class InitializerThread extends Thread {
public InitializerThread() {
b.setValue("TestValue");
}
@Override
public void run() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
UI.getCurrent().access(new Runnable() {
@Override
public void run() {
b.setValue("NewTestValue updated");
System.out.println(UI.getCurrent().getPushConfiguration().getPushMode());
}
});
}
}
private void test() {
new InitializerThread().start();
}
In my console i see printed out “AUTOMATIC” for the push mode.
When i look at the debugging console of vaadin i get:
Communication methodPush (websocket) (poll interval 3000ms)
Heartbeat300s
Is there anything i can try to solve this problem?
Vaadin version: 7.2.2
thank you for your quick response.
I’ve tried this already many times but it’s still the same problem. But it also wouldn’t make any sense cause I put the method on automatic and not manual or am i wrong?
If you have automatic you don’t need to manually push changes.
I would suggest defining the pushmode inside the annotation and not inside web.xml.
Also: Do you have vaadin-push in your classpath/dependency?
More information:
https://vaadin.com/wiki/-/wiki/Main/Enabling+server+push
That’s really weird. I justed it with your setup and it worked perfectly. Could you check if there might be some error in your logic. Maybe b isn’t added to the UI and you’re looking at another Label…
You could also try to create a new fresh Project and try it there. Maybe some setting screwed up.
If even poll didn’t work there might be a problem inside atmosphere or some server/browser issue.
So creating a new project might solve it if atmosphere gets redownloaded.
Other then that you could try testing it on another server or browser (though i suspect the problem more inside atmosphere…)
Annotations are only good for situations in which every deployment must have it. We use web.xml because it’s an easy edit and restart to switch among disabled/automatic, as well as the transport being streaming/long-polling, etc. And we can do it on one deployment without forcing it on others. Annotations mean changing the code and re-releasing it before a restart.
We have found that push still isn’t working well enough over the Internet, so our ability to turn it on/off is key. We still have issues with PDF downloads via a FileDownloader (with dynamic content created via overridden getStream()) being swallowed and then getting broken pipe exceptions when push is automatic and transport is long-polling. (So close, but PDF downloads are rather a key need in our app.)