Hi Vaadin fanatics,
I have been bit amazed how big “buzz” Artur’s
IcePush Add-on
has created among Vaadin users. Big enough to give him an iPad. Congrats! I’m bit jealous about the iPad, but I’m not convinced that it is much better (in terms of server performance and end user experience) than a simple polling solution via ProgressIndicator or Henrik’s Refresher. Same goes for pretty much all today’s main stream push implementations on the web. It sure is a nice hack for some chat apps, but it is nowhere near to be optimal long term solution for Vaadin. There are couple of issues with it that I see apparent.
The push channel is used just to indicate that there are changes on the server for the client. Another XHR is made to actually fetch them. Also for sending changes from client to server, the push channel (which is already open) isn’t used, but the std xhr method. So there is still lots of overhead from http headers and cookies, one precious http connection is used by the browser and in some cases the latency can be equal or even longer than with the infamous polling method.
Perhaps even larger pitfall is the method called push(). Its existence to be more precise. The thing best thing about Vaadin is, that you should be able to forget the client-server platform where your application is run. This sure ain’t for it. Now you know I named my todays work this way
The success of Artur’s add-on inspired me to do a prototype with tomorrows technology today. HTML5 standard has a protocol called WebSocket, which is a perfect match for Vaadin. If you haven’t heard about the WebSocket communication method, google about them. WebSockets are actually here today: in browsers they work on practically all but IE’s and several Java web servers has built a support for them.
I started up with Jetty 7, gwt-websockets and Vaadin 6.5 branch. I had to forget the gwt-websockets GWT module and replace it with own solution. It didn’t play that well in hosted mode and I was about to give up the whole idea. There is now way that I could code without debugger at this age. Hooking a new communication channel to Vaadin wasn’t that easy too, but luckily I know some guys who work with Vaadin core each and every day
Soon after a three hour fishing trip a managed to set my clear my head and the prototype to such a shape that all the UIDL communication is happening via WebSockets. Buy buy XHR! I prepared
a package to directory
for early adopters. I suggest you download it, try it and report you finding on this thread. Contributions are more than welcome. E.g. flash fallback for IE would be awesome.
Note, that the code is not even close ready for production. The code has born today and I can tell you that I have been doing more experimenting than real coding and testing. The solution is only tested on mac and webkit, but I guess it works on FF4 and latest Chrome too. Still there are some know bugs too and lots of TODO’s in the code. E.g. it only works with a one window per application and I haven’t thought at all how windows “forgotten open” should be handled. The easiest way to test this is to download the jetty distribution and launch the jetty starter (plain java app: org.vaadin.dontpush.server.DontPushServer) included in the add-on jar file. There is a very simple test app in the jar file too. Or just grab the sources via SVN.
For plain GWT user the add-on jar contains helper classes for WebSockets. The module name for all you “heretics” is: org.vaadin.dontpush.vwebsocket.VWebSocket
cheers,
matti