Javascript SSE失败:使用事件推送插件在grails中注册事件侦听器后出现问题
我有一个grails版本为2.3.8的应用程序。我安装了事件推送插件,将通知从服务器推送到浏览器。我的buildConfig.groovy如下所示Javascript SSE失败:使用事件推送插件在grails中注册事件侦听器后出现问题,javascript,events,grails,grails-plugin,Javascript,Events,Grails,Grails Plugin,我有一个grails版本为2.3.8的应用程序。我安装了事件推送插件,将通知从服务器推送到浏览器。我的buildConfig.groovy如下所示 plugins { build ":tomcat:7.0.42" compile ":events-push:1.0.M7" } grails.servlet.version = "3.0" grails.tomcat.nio=true 在我的听众看来 try { var grailsEvents = new grails.Eve
plugins {
build ":tomcat:7.0.42"
compile ":events-push:1.0.M7"
}
grails.servlet.version = "3.0"
grails.tomcat.nio=true
在我的听众看来
try {
var grailsEvents = new grails.Events("${createLink(uri:'')}", {transport: "sse"});
grailsEvents.on('ActiveCallNotification', function (data) {
console.log("GOT recording!");
});
} catch (error) {
console.log("ERROR: " + error.toString());
}
以及从控制器触发的事件
def notifyActiveCall() {
event topic: 'ActiveCallNotification',data:"hi"
}
我的事件
events = {
'ActiveCallNotification' browser: true
}
现在,当我浏览包含侦听器代码的视图时,我一次又一次地遇到以下错误:
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection. jquery.atmosphere.js:2297
SSE failed. Downgrading to fallback transport and resending
如果我在视图中对代码进行注释,则不会发生此错误,显然不考虑此事件。任何帮助都将不胜感激。我用的是铬
已安装的插件列表
compile ":scaffolding:2.0.3"
compile ':cache:1.1.2'
compile ":twitter-bootstrap:3.1.1.3"
compile ':jaxrs:0.10'
compile ":quartz:1.0.1"
compile ":joda-time:1.4"
compile ":spring-security-core:2.0-RC4"
compile ":grails-melody:1.53.0"
compile ":quartz-monitor:1.0"
compile ":audit-logging:1.0.1"
compile ":executor:0.3"
runtime ":hibernate:3.6.10.13" // or ":hibernate4:4.3.5.1"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
runtime ":resources:1.2.7"
自从您上次发表评论(2015年5月13日13:37)以来,您是否尝试过以下grails命令:
grails clean-all
grails refresh-dependencies
您还可以手动删除此处文件夹的内容:
~/.grails
它帮助我解决了类似的问题,现在已经过了一段时间,您还可以检查插件更新,使用更新的版本可以帮助解决冲突或错误的依赖关系 当我创建一个新的应用程序时,相同的代码可以完美地工作,但不能在旧的应用程序中工作。是否有可能是由于某些插件或其他冲突?