Glassfish 运行后,我在浏览器控制台(Chrome)中出现错误:

WebSocket 连接到 'ws://localhost:8080/mcweb/primepush/result-from-api?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.0.3-jquery&X-Atmosphere-Transport=websocket&X-Atmosphere- TrackMessageSize=true&X-Cache-Date=0&X-atmo-protocol=true' 失败:WebSocket 握手期间出错:意外响应代码:501

Websocket 失败。降级 cometd 重发

GlassFish 服务器 3.1.2.2

Primefaces 4.0

pom.xml

<dependency>
     <groupId>org.atmosphere</groupId>
     <artifactId>atmosphere-runtime</artifactId>
     <version>2.0.3</version>
</dependency>

网页.xml
<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <init-param>
        <param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name>
        <param-value>org.atmosphere.interceptor.HeartbeatInterceptor</param-value>
    </init-param>
    <async-supported>true</async-supported>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

最佳答案

尝试使用 Atmosphere 2.1.4 版本并将此代码段放在您的代码中:

<h:outputScript
  library="primefaces"
  name="push/push.js"
  target="head"
/>

关于primefaces - Atmosphere 误差 : Error during WebSocket handshake: Unexpected response code: 501,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25549792/

10-13 01:02