在我基于primefaces的应用程序中,我使用大气框架将数据从服务器推送到客户端。我将应用程序部署到tomcat 7.0.54。如果我通过ip和端口访问应用程序,一切似乎都很好。使用localhost或远程服务器ip并不重要,它完美无缺。但是,当我尝试通过Apache2后面的http://domainNameWithoutPort.com/appName访问应用时,Atmosphere会在客户端(在Chrome上)抛出这些异常:
WebSocket connection to 'ws://domain.com/appName/primepush/liveStream?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.0.8&X-Atmosphere-Transport=websocket&X-Cache-Date=0' failed: Error during WebSocket handshake: Unexpected response code: 501 domain.com/appName/javax.faces.resource/push/push.js.xhtml?ln=primefaces:1
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
Websocket closed, wasClean: false
Websocket failed. Downgrading to Comet and resending
Failed to load resource: the server responded with a status of 501 (Not Implemented) http://domain.com/appName/primepush/liveStream?X-Atmosphere-tracking-id=0…k=1.0.8&X-Atmosphere-Transport=long-polling&X-Cache-Date=0&_=140722464408
服务器端的那些例外:
org.atmosphere.cpr.AsynchronousProcessor - Invalid request state. Websocket protocol not supported
org.atmosphere.cpr.AsynchronousProcessor - Invalid request state. AsyncContext#startAsync not supported. Make sure async-supported is set to true in web.xml
并最终没有更新客户端。我在<async-supported>true</async-supported>
中定义了web.xml
,但没有运气。
使用过的技术的版本; Primefaces版本:3.5,Atmosphere版本:2.1.5,Tomcat 7.0.54
希望有人知道这个伎俩,
谢谢大家。
答案 0 :(得分:1)
使用AJP(在httpd和Tomcat之间)时,不支持Comet和WebSocket。如果你使用mod_proxy_http Comet应该可以工作。