【问题标题】:JSF 2.3 & o:socket or f:websocket - Nothing 'pushed' to the clientJSF 2.3 & o:socket 或 f:websocket - 没有“推送”到客户端
【发布时间】:2018-04-18 17:34:45
【问题描述】:

在@BalusC 的帮助下,我的 EJB 方法使用在 EE8 上运行的 JSF 2.3 在 JBoss WildFly 12.0.0.Final (MacOS) 上触发了一个事件:

beanManager.fireEvent("updateNotifications" );

POJO:

@Inject
@Push(channel = "testChannel")
private PushContext pushContext;

public void onPersist(@Observes String notification) {
    logger.info("***** onPersist notification = {}", notification);
    pushContext.send("updateNotifications");
}

接收并打印消息;

16:03:36,682 信息 [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (默认任务 3)>>>>> insertFoodsCosmeticsMedicinesEJB beanManager = 焊接 NOTiFYwell.ear/NOTiFYwellJAR.jar/ [bean count=39] 的 BeanManager

16:03:36,695 INFO [com.notifywell.push.PushBean](默认任务 3) ***** onPersist 通知 = updateNotifications

我无法让它通过 Push Send 与 XHTML 通信。我已经尝试过使用 OmniFaces 3.1 和 JBoss WildFly 12 JSF 2.3 并且没有重新渲染(此处未显示 XHTML 代码)。使用 OmniFaces 3.1 时,我无法显示 onmessage:

<h:form>
    <o:socket channel="testChannel" onmessage="socketListener"/>
    <h:outputScript>
        function socketListener(message, channel, event) {
            console.log(message);
        }
    </h:outputScript>
</h:form>

如果我在 Chrome 中打开控制台日志,它是空的,没有“消息”。

在 WireShark 中我看到了:

2601 9.810264 ::1 ::1 HTTP 997 GET /NOTiFYwell/omnifaces.push/testChannel?a1ef3363-dc5a-4153-a4c7-73b0e183713d HTTP/1.1

好像是

pushContext.send(notification);

没有被执行。

【问题讨论】:

  • 你在浏览器中调试过网络流量吗?
  • 使用 Wireshark 过滤 tcp.port == 8080 && http。我看到我的单元测试正在运行。是否显示 HTTP GET 和 OK 200 的响应。
  • “好像pushContext.send(notification) 没有被执行。” 调试...
  • uhhhh 如果您从 ide 在容器中运行您的应用程序,您应该能够调试...
  • 如果你有minimal reproducible example 我可以尝试复制。但我不会尝试复制。但是 f: websockets 有效吗?这有什么不同吗?

标签: jsf wildfly omnifaces jsf-2.3


【解决方案1】:

我与 Wildfly 14 的情况完全相同。

要解决这个问题,我必须:

  1. 取消部署应用程序
  2. 关闭服务器
  3. 在standalone中清除tmp文件夹的内容
  4. 启动服务器
  5. 部署

现在它可以工作了,但是如果我在没有步骤 1-4 的情况下进行部署,它将无法再次工作。 (也许第 3 步不是必需的,但我这样做是因为我遇到了很多其他错误)

【讨论】:

    猜你喜欢
    • 2018-09-26
    • 1970-01-01
    • 2013-02-04
    • 2014-10-22
    • 2017-12-18
    • 1970-01-01
    • 2018-09-26
    • 1970-01-01
    • 2013-03-05
    相关资源
    最近更新 更多