Vaadin cannot establish Websocket connection on OpenShift

て烟熏妆下的殇ゞ 提交于 2019-12-24 07:25:17

问题


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? ;-) 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 ;(


回答1:


The default front proxy used by OpenShift don't yet support WebSockets. I have heard they are about to update it soonish. Until that you can use their experimental alternative proxy from port 8000 that already supports web sockets. In your case it can be reached from address:

http://t8-drewconnect.rhcloud.com:8000/web/

Also note that polling (UI.setPollingInterval(int)), is often good enough most purposes.



来源:https://stackoverflow.com/questions/25967877/vaadin-cannot-establish-websocket-connection-on-openshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!