Atmosphere with Tomcat8

Hello all,
I’m using Vaadin 7.3 with Tomcat8 (built manually from sources on the server) on the OpenShift server. My other setup is Tomcat7 7.0.54 also on OpenShift. My problem appears on both those configurations.
Here’s what happens: while I’m opening my Vaadin application with the @Push support enabled, I get the following error:

WebSocket connection to 'ws://t8-drewconnect.rhcloud.com/web/PUSH/?v-uiId=0&v-csrfToken=4097664e-4d3b-4dd6-9474-0a6441986e9a&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.1.5.vaadin4-jquery&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-Cache-Date=0&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true' failed: Error during WebSocket handshake: Unexpected response code: 501 ​Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). vaadinPush.debug.js:13176 Websocket closed, wasClean: false vaadinPush.debug.js:13176 Mon Sep 22 07:39:46 GMT+200 2014 com.vaadin.client.VConsole INFO: Push connection closed com.drewconnect.web.AppWidgetSet-0.js:4714 Websocket failed. Downgrading to Comet and resending vaadinPush.debug.js:13176 Mon Sep 22 07:39:46 GMT+200 2014 com.vaadin.client.VConsole INFO: Push connection using primary method (websocket) failed. Trying with long-polling I have spent good amount of time reading on the web, what can be done about it, read about enabling native atmosphere support etc. and was about to configure it, when I discovered, that Vaadin uses Atmosphere bundled into atmosphere-runtime-2.1.2.vaadin3.jar, which I’m not sure if I can get rid of. This Atmosphere article https://github.com/Atmosphere/atmosphere/wiki/Installing-AtmosphereServlet-with-or-without-native-support suggests using atmosphere-runtime-native but it looks like Vaadin uses some customised version…

Strangely on the localhost (in my dev environment) the WebSockets connection is being established without any problems…

Am I on a good way to fix the problem or am I somewhere completely else? :wink: Do you guys know the solution to this problem?
I would appreciate the answer, because negotiation between websockets and long-polling takes a lot of time - I have to wait for about 2 minutes before the application reacts, and sometime it never finishes (at the top of the screen there’s a blinking progress bar, which never gets to 100%).
My customer, I’ve presented the demo of the application to, cannot connect in 9 out of 10 cases and so I’m completely stuck - without seeing the demo he won’t go any further with me ;(

Did you ever find a solution to this? I started having this exact problem recently using Vaadin 7.4.8.

I am getting exact same error. Is there anz fix to that? I am using Vaadin 7.7.6 on Tomcat 7 on my server. Is there any reason to get this on Server Configurations maybe?

Hello, I had websocket connection problems before and I strongly suggest enabling TLS (HTTPS) on your server and trying again. Problems related to websockets connectivity went away as soon as I switched to TLS. It may be related to some intermediaries on the internet.

If the problem still persists, then it may be related to Tomcat configuration. I would then suggest using Spring Boot’s embedded Tomcat, which works perfectly with Vaadin’s push support over the net.

Hello,

Thanks for your reply. I have two questions.
1- Enabling TLS HTTPS without a valid certificate is also OK?
2- I have looked over google to find how to embed Spring Boot to Tomcat but I am empty handed. Can you send me a link which explains how?

Thanks

Hi Cantek,

You have to use a valid certificate or your clients will not use your application. You don’t need to buy one, I use LetsEncrypt for all my servers, which is a free CA.

To transition an existing Vaadin project to Spring Boot + Vaadin,

  1. Go to
    start.spring.io
    , select Vaadin, download the demo application,
  2. Copy Application class and parts of pom.xml (especially the parent, depencencyManagement and plugin parts) to your app,
  3. Annotate your Vaadin UI’s with @SpringUI(path = ""),
  4. Run your application by mvn spring-boot:run command, which automatically runs the embedded auto configured Tomcat. You don’t need to use any other Spring Framework feature.
  5. These are all basic steps required to run the app, for your information I recommend reading the always
    up-to-date official guide
    for a complete understanding of Spring Boot.

Good luck.

Thanks,

I will try with LetsEncrypt.

I use IVY in my applicaitons, in that case this is not feasable for me I guess.

When I call my app from IP address:8080/projectName/ everythig works fine. But when I call it from the Virtual host domain that set for the same app as https://domainname/app/ push Handshake is not done and returns 501 on initialization:

/app/PUSH?v-uiId=2&v-csrfToken=c13c3453-6256-…e=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true’ failed: Error during WebSocket handshake: Unexpected response code: 501

and after that on every heartbeat it returns :

/app/PUSH?v-uiId=1&v-csrfToken=c13c3453-625…plication%2Fjson%3B%20charset%3DUTF-8&X-atmo-protocol=true&_=1489743209395 net::ERR_INCOMPLETE_CHUNKED_ENCODING

I am still looking into this, I hope someone can help on that.

Are you using a reverse proxy server such as (apache, nginx, haproxy) in-between?

Yes,

I am running my server on Apache, there is tomcat on it. I have mod_proxy settings configured but not sure how correct they are.

You need specific configuration for websockets to work properly via reverse proxies. I have ready to use configuration for nginx but not for apache2.

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;