Grails氛围插件浏览器在几个请求后挂起

时间:2013-12-21 06:35:45

标签: java grails atmosphere

在grails中使用大气插件,在向服务器发出一些请求之后(在几页导航之后),浏览器没有呈现任何页面而只是加载。其他系统中的其他浏览器工作正常。连接到服务器的代码放在公共布局页面中。 服务器代码:

def onRequest = { event ->
    def userBroadcasters= ServletContextHolder.servletContext.getAttribute('userBroadcasters')
    def uid=event.getRequest().session.user?.id
    if(!userBroadcasters){
        userBroadcasters=[:]
    }
    Broadcaster privateChannel = BroadcasterFactory.getDefault().lookup("/userChannel"+uid, true);
    privateChannel.addAtmosphereResource(event)
    userBroadcasters.put(uid,privateChannel)
    ServletContextHolder.servletContext.setAttribute('userBroadcasters',userBroadcasters)
    event.suspend()
    //println ServletContextHolder.servletContext.getAttribute('userBroadcasters')
    //println "Inside onRequest!"
}

常见布局的客户端代码:

function callback(response) {
            if (response.status == 200 && response.responseBody.length > 0) {
               //action
            }
        }

        var location = '${request.contextPath}/atmosphere/mx';
        var request = {transport: "streaming", fallbackTransport: 'long-polling', contentType: "application/json",connectTimeout:4000};
        $.atmosphere.subscribe(location, callback, request);

0 个答案:

没有答案