Blog

Vaadin 7.6 preview: Improved communication mechanism

By  
Artur Signell
Artur Signell
·
On Sep 24, 2015 11:30:00 AM
·

Have you ever seen this nasty warning?

ReindeerCriticalNotificationsTest-communicationError_Windows_Chrome_40_systemnotification.png

If so, Vaadin 7.6 will bring better times for you with its improved communication. It has better fault tolerance, error handling and feedback to the user!

Error handling before was very simple

The handling of temporary communication problems in Vaadin 7.5 and earlier is quite straightforward. If there is a problem sending a request to the server, show the "Communication problem" dialog and make the user refresh the application. If we are using push, instead try to re-establish the push connection and show the spinner to the user. If we cannot ever re-establish the connection (or even establish it once), keep the spinner spinning forever.

Showing the "Communication problem" or an eternal spinner to the end user is never the right thing to do. So in Vaadin 7.6 we have rewritten how errors are handled and unified the handling so it is the same, not matter if you are using push or not.

Enter the reconnect dialog

Starting from 7.6, you will no longer see an eternal spinner or a "Communication error" message, you will instead see a reconnect dialog. In the background the browser will try to re-send whatever you were sending to the server and resynchronize the server and the client, if some message somehow got lost during transit. When the connection has been re-established, the dialog will automatically disappear and the application will continue to work as you would expect.

Screen Shot 2015-09-01 at 13.11.13 .png

Look and feel

The look and feel above is the default and can be customized according to your needs. The dialog is made as a custom GWT widget, which you can completely replace if you want to. Smaller tweaks to the behavior can be done using UI.getReconnectDialogConfiguration(), through which you can adjust parameters such as the interval between reconnect attempts, max number of attempts, a delay before showing the dialog and the text to show in the dialog.

Push is more reliable, once again

While unifying the error handling of push and XHR communications, we also made some fundamental changes to how the push connection is handled in Vaadin. Earlier when using push, we have been using the push channel for communications both from the server to the client (traditional push) and from the client to the server. To be able to use the push channel both ways, we have been waiting for confirmation that the push channel is up and available before sending any messages to the server. When there was a buffering proxy between the client and the server, it was sometimes the case that this confirmation never arrived. As a result, the application would never work.

Now we are using push only for server initiated communication when there can be proxy problems (long polling) and for both server and client initiated communication when using websockets (we get reliable connection info). This improves two things:

  1. Buffering proxies are no longer an issue

  2. If the push channel for some reason does not work, the rest of the application will still work the same way as if push was not enabled

At the same time we made it possible to optionally use XHR for client initiated communication even when websockets are in use. This enables HTTP bound features (JAAS, cookies, …) to work even if you are using websockets for push.

Try it today

The first version of all the described changes are available in Vaadin 7.6.0.alpha6. Update the version in your project's pom.xml or ivy.xml, add the Vaadin pre-release repository if not already there, recompile the widget set and you are ready to go.

If you just want to get a quick idea of what it looks like for the user, go to http://artur.app.fi/simulate-network-error/ and fiddle with the buttons and options.

Try Vaadin 7.6 Alpha 6 today

Artur Signell
Artur Signell
Artur Signell works as CTO at Vaadin. He earlier lead the Vaadin products team and was responsible for all Vaadin products. Currently he is focusing on technology and research.
Other posts by Artur Signell