Primefaces推罐';无法获得工作的动态路径

Primefaces推罐';无法获得工作的动态路径,primefaces,push,atmosphere,Primefaces,Push,Atmosphere,这项工作: <p:socket channel="/redirectMonitoring"> <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" /> </p:socket> Facelet代码段: <p:socket channel="/redirectMonitoring"> <p:ajax event="message"

这项工作:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
Facelet代码段:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
CDIBean:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
@Model
public class RedirectBean {
    public void redirect() {
        EventBus eventBus = EventBusFactory.getDefault().eventBus();
        eventBus.publish("/redirectMonitoring", Boolean.TRUE);
    }
}
@Model
public class RedirectBean {
    public void redirect(String sessionId) {
        EventBus eventBus = EventBusFactory.getDefault().eventBus();
        eventBus.publish("/redirectMonitoring/" + sessionId, "/foo.xhtml");
    }
}
但当我尝试使路径动态时,如下所示:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
Facelet:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
<p:socket onMessage="handleMessage" channel="/redirectMonitoring/{sessionId}" autoConnect="false" widgetVar='subscriber'/>
<script type="text/javascript">
    function handleMessage(message) {
        window.location.replace(message);
    }
</script>
资源:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
@PushEndpoint("/redirectMonitoring")
@Singleton
public class RedirectMonitorResource {
    @OnMessage() public void onMessage(Boolean ignore) {}
}
@PushEndpoint("/redirectMonitoring/{sessionId}")
@Singleton
public class RedirectMonitorResource {
    @PathParam("sessionId") private String sessionId;

    @OnMessage(encoders = {JSONEncoder.class}) public String onMessage(String message) { return message; }
}
CDIBean:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
@Model
public class RedirectBean {
    public void redirect() {
        EventBus eventBus = EventBusFactory.getDefault().eventBus();
        eventBus.publish("/redirectMonitoring", Boolean.TRUE);
    }
}
@Model
public class RedirectBean {
    public void redirect(String sessionId) {
        EventBus eventBus = EventBusFactory.getDefault().eventBus();
        eventBus.publish("/redirectMonitoring/" + sessionId, "/foo.xhtml");
    }
}
web浏览器未加载/foo.xhtml,我在日志中发现以下错误:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
20:12:24,811 ERROR [org.atmosphere.container.JSR356Endpoint] (default I/O-5) : java.io.IOException: An existing connection was forcibly closed by the remote host
    at sun.nio.ch.SocketDispatcher.read0(Native Method) [rt.jar:1.8.0_05]
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) [rt.jar:1.8.0_05]
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) [rt.jar:1.8.0_05]
    at sun.nio.ch.IOUtil.read(IOUtil.java:192) [rt.jar:1.8.0_05]
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:375) [rt.jar:1.8.0_05]
    at org.xnio.nio.NioSocketConduit.read(NioSocketConduit.java:280) [xnio-nio-3.2.2.Final.jar:3.2.2.Final]
    at org.xnio.conduits.AbstractStreamSourceConduit.read(AbstractStreamSourceConduit.java:51) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at org.xnio.ssl.JsseSslStreamSourceConduit.read(JsseSslStreamSourceConduit.java:84) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.conduits.IdleTimeoutConduit.read(IdleTimeoutConduit.java:144)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.server.protocol.framed.AbstractFramedChannel.receive(AbstractFramedChannel.java:244)
    at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:20)
    at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:15)
    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:632)
    at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:618)
    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:87) [xnio-nio-3.2.2.Final.jar:3.2.2.Final]
    at org.xnio.nio.WorkerThread.run(WorkerThread.java:539) [xnio-nio-3.2.2.Final.jar:3.2.2.Final]
另外,我设置了断点以确保会话id在

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
"PF('subscriber').connect('/redirectMonitoring/" + WebUtil.getSession().getId() + "')"
eventBus.publish("/redirectMonitoring/" + sessionId, "/foo.xhtml");
与中的会话id匹配

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
"PF('subscriber').connect('/redirectMonitoring/" + WebUtil.getSession().getId() + "')"
eventBus.publish("/redirectMonitoring/" + sessionId, "/foo.xhtml");
如有任何建议/指示/建议,将不胜感激

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
更新:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
我使用的是PrimeFaces 5.2+大气2.3.4

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
我确实将
p:socket
更改为
autoConnect=“true”
,但这样做没有帮助

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
以下是当浏览器针对web应用程序发出请求时,我通过浏览器控制台/网络选项卡看到的内容:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
https://localhost:8443/app/primepush/redirectMonitoring/%7BsessionId%7D?X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=5f40ca65-0ab0-4c4c-ab58-7b9b790eb78f&_=1440535767013

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
但是,当web应用程序尝试通过
/redirectMonitoring
端点向web浏览器发送消息时,我在console/network选项卡上看不到任何活动

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
这里还有一条线索:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
当我在静态路径版本的RedirectMonitorResource#onMessage上设置断点时,该断点在调试会话中被触发:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
@PushEndpoint("/redirectMonitoring")
@Singleton
public class RedirectMonitorResource {
    @OnMessage() 
    public void onMessage(Boolean ignore) {} // <-- breakpoint here is triggered
}
@PushEndpoint(“/redirectMonitoring”)
@独生子女
公共类重定向MonitorResource{
@OnMessage()

public void onMessage(Boolean ignore){}/解决方案是从以下内容更改p:socket通道属性:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
<p:socket channel="/redirectMonitoring/{sessionId}" ... />

为此:

<p:socket channel="/redirectMonitoring">
    <p:ajax event="message" oncomplete="window.location.replace('/foo.xhtml')" />
</p:socket>
<p:socket channel="/redirectMonitoring/#{session.id}" ... />


Duplicate?不,不是重复的,因为(1)该问题不表示正在抛出异常;(2)我使用的是Primefaces 2.3.4,这是该问题的答案。除了聊天应用程序之外,没有任何使用在线动态路径的简单工作示例吗?所有示例都使用静态路径。你的意思是大气2.3.4。请将所有此类信息添加到问题中。日志d中没有提到错误oes并不意味着没有。它是否与autoconnect=true一起工作?浏览器控制台/网络选项卡如何?任何信息?另一篇文章包含一个示例。showcase示例有什么问题?啊,是的,Atmosphere 2.3.4(我发布问题时Atmosphere-2.3.4标记不可用)。关于日志中没有提及错误的观点很好。我更新了问题以回答您的问题。很好,很抱歉我错过了。但是如上所述,showcase是有效的,所以将其与您的示例进行“比较”总是很好的。@Kukeltje在阅读您的建议后,我确实尝试让showcase工作。我删除了JSF JAR,以便它能够正常工作正确部署到Wildfly。然后,我启用了chat.xhtml的
用户名:inputText
命令按钮,它们被禁用。但它没有正常工作。我能够让用户显示在彼此的
用户数据列表中,但遗憾的是没有来回的消息。但无论如何,这是一个不同的问题,我确实做到了Y