我正在尝试集成grails events-push插件以将事件推送到浏览器,但是它不起作用。我为此做了以下更改
BuildConfig.groovy
grails.tomcat.nio = true
compile ":events-push:1.0.M7"
Config.groovy
events.push.servlet.initParams = [
'org.atmosphere.cpr.cometSupport': 'org.atmosphere.container.Tomcat7CometSupport',
"org.atmosphere.cpr.CometSupport.maxInactiveActivity": "100000"
]
tomcat.nio=true
由于tomcat无法使用,因此从META-INF文件夹中删除了context.xml(由插件生成)
在客户端,即角度js
window.grailsEvents = new grails.Events('http://localhost:8080');
我设法成功启动了我的应用程序。我也在日志下面的消息
DEBUG cpr.DefaultBroadcaster - Broadcaster eventsbus doesn't have any associated resource. Message will be cached in the configured BroadcasterCache
当我在浏览器websocket中打开应用程序时,卜不起作用。在服务端,我看到以下消息
2014-05-01 15:19:56,365 [http-nio-8080-exec-3] DEBUG cpr.AsynchronousProcessor - Timing out the connection for request AtmosphereRequest{ contextPath= servletPath=/g-eventsbus pathInfo=/eventsbus requestURI=/g-eventsbus/eventsbus requestURL=http://localhost:8080/g-eventsbus/eventsbus destroyable=false}
2014-05-01 15:19:56,366 [http-nio-8080-exec-3] WARN websocket.DefaultWebSocketProcessor - Unable to retrieve AtmosphereResource for org.apache.catalina.websocket.WsOutbound@269dd750
2014-05-01 15:19:57,783 [http-nio-8080-exec-5] DEBUG cpr.AsynchronousProcessor - Timing out the connection for request AtmosphereRequest{ contextPath= servletPath=/g-eventsbus pathInfo=/eventsbus requestURI=/g-eventsbus/eventsbus requestURL=http://localhost:8080/g-eventsbus/eventsbus destroyable=false}
我在浏览器控制台端看到了
WebSocket connection to 'ws://localhost:8080/g-eventsbus/eventsbus?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.1.0.beta3&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-Cache-Date=0&topics=eventsbus' failed: WebSocket is closed before the connection is established.
伙计们,请帮帮我,我长期以来一直在努力使用此插件。
感谢mpccolorado您的回复。我知道它实际上在JS grails中起作用。事件应该使用globalTopicName创建。
var grailsEvents = new grails.Events(GRAILS_EVENT_URL, {globalTopicName: 'newReview'});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句