只有在webserver重启后,Cometd订阅才能在IE中运行

时间:2014-10-01 23:00:06

标签: jquery internet-explorer-9 cometd

我有一个有趣的问题只出现在Internet Explorer(版本9)而不是其他浏览器 - chrome / opera / firefox / safari正常工作,所以我不怀疑spring / cometd有什么问题/ bayeux配置。

编辑:看起来IE在页面加载时发送多个握手请求,而其他浏览器只发送一个,在weserver重启时只发送一个握手请求。

在IE中,init,handshake和connect运行良好但订阅请求没有接收广播,但是,如果在IE页面等待的同时重新启动Web服务器,则按预期接收所有后续广播。如果刷新IE页面,则它将恢复为不接收广播。

我最初认为这可能是IE连接问题,因此明确将每台服务器的最大连接数设置为10(请参阅http://msdn.microsoft.com/en-us/library/cc304129(VS.85).aspx),但这还没有解决。

脚本:

...

function startSubscriptionStats() {
    cometd.subscribe('/msgs', function (msg) {
        ...
    });
}

function startSubscriptionMsgs() {
    cometd.subscribe('/msgs', function (msg) {
        ...
    });
}

$(function () {
try {
    cometd.registerTransport('long-polling', new org.cometd.LongPollingTransport());
    cometd.registerTransport('callback-polling', new org.cometd.CallbackPollingTransport());
    cometd.getExtension('reload').configure({cookieMaxAge: 15});

    // Configure the cometd bayeux url using the current path with the '/ui' replaced with '/cometd'
    var cometdUrl = document.location.href.match(/^(.*)\/ui\//)[1] + '/cometd';
    cometd.init({
        url: cometdUrl,
        logLevel: 'error',
        appendMessageTypeToURL: false
    });

    // register handshake with callback function that starts the subscriptions
    cometd.addListener('/meta/handshake', function (handshake) {
        if (handshake.successful === true) {
            cometd.batch(function () {
                startSubscriptionStats();
                startSubscriptionMsgs();
            });
        }
    });

    // regiser connection callback function that displays modal on disconnect
    cometd.addListener('/meta/connect', function (connect) {
        if (connect.successful === false) {
            probCounter++;
            if (probCounter > 5) {
                showModal("Warning", "Connection to server has been lost - data displayed might be out of date");
                probCounter = 0;
            }
        } else {
            probCounter = 0;
            if (hideModal()) {
                requestData("boardData", initiliseBoard);
            }
        }
    });

    // kick off handshake that should trigger the listener callback above
    debugMsg("Sending handshake request to " + cometdUrl);
    cometd.handshake();
} catch (e) {
    alert("Failed to start up comet: " + e.message);
}

握手回调开始说明:

cometd.addListener('/meta/handshake', function (handshakeReply) {
    debugMsg("Handshake responded " + handshakeReply.successful);
    if (handshakeReply.successful === true) {
        cometd.batch(function () {
            startSubscriptionStats();
            startSubscriptionMsgs();
        });
    }
});

如果有帮助,这是相关的服务器日志输出:

2014-10-03 09:08:02,402 CommandController INFO Index requested
2014-10-03 09:08:02,405 CometConfigurer INFO Configuring service nzgui
2014-10-03 09:08:03,562 AbstractLifeCycle DEBUG starting nz.eftpos.internode.gui.support.JacksonBayeuxServerImpl@1a71ec39
2014-10-03 09:08:03,562 443673657 DEBUG Allowed Transports: [callback-polling, long-polling]
2014-10-03 09:08:03,563 AbstractLifeCycle DEBUG STARTED nz.eftpos.internode.gui.support.JacksonBayeuxServerImpl@1a71ec39
2014-10-03 09:08:03,632 443673657 DEBUG >  {id=2, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0} null
2014-10-03 09:08:03,632 443673657 DEBUG >> {id=2, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0}
2014-10-03 09:08:03,642 443673657 DEBUG >  {id=1, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0} null
2014-10-03 09:08:03,642 443673657 DEBUG >> {id=1, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0}
2014-10-03 09:08:03,683 443673657 DEBUG << {id=2, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=3oavlsfa2fymkb9u87r3qiawi, version=1.0}
2014-10-03 09:08:03,683 443673657 DEBUG << {id=1, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=4ycca35alnk94ret0g8ksw6rt, version=1.0}
2014-10-03 09:08:03,684 443673657 DEBUG <  {id=2, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=3oavlsfa2fymkb9u87r3qiawi, version=1.0}
2014-10-03 09:08:03,684 443673657 DEBUG <  {id=1, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=4ycca35alnk94ret0g8ksw6rt, version=1.0}
2014-10-03 09:08:03,733 443673657 DEBUG >  {id=3, subscription=/stats, channel=/meta/subscribe, clientId=3oavlsfa2fymkb9u87r3qiawi} 3oavlsfa2fymkb9u87r3qiawi - last connect 0 ms ago
2014-10-03 09:08:03,733 443673657 DEBUG >> {id=3, subscription=/stats, channel=/meta/subscribe, clientId=3oavlsfa2fymkb9u87r3qiawi}
2014-10-03 09:08:03,735 443673657 DEBUG No authorizers, CREATE for channel /stats granted
2014-10-03 09:08:03,735 443673657 DEBUG Added channel /stats
2014-10-03 09:08:03,735 443673657 DEBUG No authorizers, SUBSCRIBE for channel /stats granted
2014-10-03 09:08:03,736 443673657 DEBUG No authorizers, SUBSCRIBE for channel /stats granted
2014-10-03 09:08:03,736 443673657 DEBUG << {id=3, subscription=/stats, successful=true, channel=/meta/subscribe}
2014-10-03 09:08:03,736 443673657 DEBUG <  {id=3, subscription=/stats, successful=true, channel=/meta/subscribe}
2014-10-03 09:08:03,736 443673657 DEBUG >  {id=4, subscription=/msgs, channel=/meta/subscribe, clientId=3oavlsfa2fymkb9u87r3qiawi} 3oavlsfa2fymkb9u87r3qiawi - last connect 0 ms ago
2014-10-03 09:08:03,736 443673657 DEBUG >> {id=4, subscription=/msgs, channel=/meta/subscribe, clientId=3oavlsfa2fymkb9u87r3qiawi}
2014-10-03 09:08:03,737 443673657 DEBUG No authorizers, CREATE for channel /msgs granted
2014-10-03 09:08:03,737 443673657 DEBUG Added channel /msgs
2014-10-03 09:08:03,737 443673657 DEBUG No authorizers, SUBSCRIBE for channel /msgs granted
2014-10-03 09:08:03,737 443673657 DEBUG No authorizers, SUBSCRIBE for channel /msgs granted
2014-10-03 09:08:03,737 443673657 DEBUG << {id=4, subscription=/msgs, successful=true, channel=/meta/subscribe}
2014-10-03 09:08:03,737 443673657 DEBUG <  {id=4, subscription=/msgs, successful=true, channel=/meta/subscribe}
2014-10-03 09:08:03,740 443673657 DEBUG >  {id=5, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} 4ycca35alnk94ret0g8ksw6rt - last connect 0 ms ago
2014-10-03 09:08:03,740 443673657 DEBUG >> {id=5, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:08:03,741 443673657 DEBUG << {id=5, successful=true, advice={interval=0, reconnect=retry, timeout=30000}, channel=/meta/connect}
2014-10-03 09:08:03,741 443673657 DEBUG <  {id=5, successful=true, advice={interval=0, reconnect=retry, timeout=30000}, channel=/meta/connect}
2014-10-03 09:08:04,439 443673657 DEBUG <  {id=1, data={contents=[nz.eftpos.internode.gui.web.model.Status@18e5d214, nz.eftpos.internode.gui.web.model.Status@18432bd1, nz.eftpos.internode.gui.web.model.Status@61f1b2c8, nz.eftpos.internode.gui.web.model.Status@43109ab4, nz.eftpos.internode.gui.web.model.Status@771cc1d1, nz.eftpos.internode.gui.web.model.Status@f8bd6f], type=statusUpdate}, channel=/stats}
2014-10-03 09:08:04,830 443673657 DEBUG >  {id=6, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} 4ycca35alnk94ret0g8ksw6rt - last connect 0 ms ago
2014-10-03 09:08:04,830 443673657 DEBUG >> {id=6, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:08:04,831 443673657 DEBUG << {id=6, successful=true, channel=/meta/connect}
2014-10-03 09:08:05,573 443673657 DEBUG <  {id=2, data={contents=[nz.eftpos.internode.gui.web.model.Status@8f738f8, nz.eftpos.internode.gui.web.model.Status@1ebd2661, nz.eftpos.internode.gui.web.model.Status@1422ba0b, nz.eftpos.internode.gui.web.model.Status@73e43280, nz.eftpos.internode.gui.web.model.Status@aafacf1, nz.eftpos.internode.gui.web.model.Status@138307b2], type=statusUpdate}, channel=/stats}
2014-10-03 09:08:08,423 443673657 DEBUG <  {id=3, data={contents=[], type=board}, channel=/msgs}
2014-10-03 09:08:10,954 443673657 DEBUG <  {id=4, data={contents=[nz.eftpos.internode.gui.web.model.Status@197bd7b3, nz.eftpos.internode.gui.web.model.Status@118e35d7, nz.eftpos.internode.gui.web.model.Status@f70bf42, nz.eftpos.internode.gui.web.model.Status@331c8df9, nz.eftpos.internode.gui.web.model.Status@17acf0a6, nz.eftpos.internode.gui.web.model.Status@5aeb2e6e], type=statusUpdate}, channel=/stats}
2014-10-03 09:08:12,431 443673657 DEBUG <  {id=5, data={contents=[nz.eftpos.internode.gui.web.model.Status@49e11d13, nz.eftpos.internode.gui.web.model.Status@5a3bf049, nz.eftpos.internode.gui.web.model.Status@151c76e7, nz.eftpos.internode.gui.web.model.Status@7fc24284, nz.eftpos.internode.gui.web.model.Status@2a9d29a3, nz.eftpos.internode.gui.web.model.Status@3418a230], type=statusUpdate}, channel=/stats}
2014-10-03 09:08:13,574 443673657 DEBUG <  {id=6, data={contents=[nz.eftpos.internode.gui.web.model.Status@3d401808, nz.eftpos.internode.gui.web.model.Status@3ae9d4a2, nz.eftpos.internode.gui.web.model.Status@4d86f5e5, nz.eftpos.internode.gui.web.model.Status@5779b526, nz.eftpos.internode.gui.web.model.Status@7763fea7, nz.eftpos.internode.gui.web.model.Status@45e3c32d], type=statusUpdate}, channel=/stats}
2014-10-03 09:08:14,327 ServerSession DEBUG Sweeping session 3oavlsfa2fymkb9u87r3qiawi - last connect 0 ms ago
2014-10-03 09:08:14,327 443673657 DEBUG Removing session 3oavlsfa2fymkb9u87r3qiawi - last connect 0 ms ago, timed out: true
2014-10-03 09:08:14,328 ServerSession DEBUG Sweeping session 2efvlc43yyn7w1jrb69dv62kmw - last connect 0 ms ago
2014-10-03 09:08:14,328 443673657 DEBUG Removing session 2efvlc43yyn7w1jrb69dv62kmw - last connect 0 ms ago, timed out: true
2014-10-03 09:08:14,328 ServerSession DEBUG Sweeping session 1nszhseiycs785a9adjif7o1t - last connect 0 ms ago
2014-10-03 09:08:14,328 443673657 DEBUG Removing session 1nszhseiycs785a9adjif7o1t - last connect 0 ms ago, timed out: true
2014-10-03 09:08:15,542 443673657 DEBUG Removed channel /stats
2014-10-03 09:08:15,543 443673657 DEBUG Removed channel /msgs
2014-10-03 09:08:35,452 443673657 DEBUG <  {id=6, successful=true, channel=/meta/connect}
2014-10-03 09:08:35,468 443673657 DEBUG >  {id=7, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} 4ycca35alnk94ret0g8ksw6rt - last connect 30621 ms ago
2014-10-03 09:08:35,468 443673657 DEBUG >> {id=7, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:08:35,468 443673657 DEBUG << {id=7, successful=true, channel=/meta/connect}
2014-10-03 09:09:06,459 443673657 DEBUG <  {id=7, successful=true, channel=/meta/connect}
2014-10-03 09:09:06,478 443673657 DEBUG >  {id=8, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} 4ycca35alnk94ret0g8ksw6rt - last connect 30991 ms ago
2014-10-03 09:09:06,478 443673657 DEBUG >> {id=8, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:09:06,479 443673657 DEBUG << {id=8, successful=true, channel=/meta/connect}
2014-10-03 09:09:37,475 443673657 DEBUG <  {id=8, successful=true, channel=/meta/connect}
2014-10-03 09:09:37,490 443673657 DEBUG >  {id=9, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} 4ycca35alnk94ret0g8ksw6rt - last connect 30996 ms ago
2014-10-03 09:09:37,491 443673657 DEBUG >> {id=9, connectionType=long-polling, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:09:37,491 443673657 DEBUG << {id=9, successful=true, channel=/meta/connect}

这是重新启动网络服务器后的日志,客户端开始接收广播时的日志:

2014-10-03 09:24:37,514 AbstractLifeCycle DEBUG starting nz.eftpos.internode.gui.support.JacksonBayeuxServerImpl@f9c27e4
2014-10-03 09:24:37,514 261892068 DEBUG Allowed Transports: [callback-polling, long-polling]
2014-10-03 09:24:37,515 AbstractLifeCycle DEBUG STARTED nz.eftpos.internode.gui.support.JacksonBayeuxServerImpl@f9c27e4
2014-10-03 09:24:37,578 261892068 DEBUG >  {id=39, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt} null
2014-10-03 09:24:37,578 261892068 DEBUG >> {id=39, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=4ycca35alnk94ret0g8ksw6rt}
2014-10-03 09:24:37,578 261892068 DEBUG << {id=39, error=402::Unknown client, successful=false, advice={interval=0, reconnect=handshake}, channel=/meta/connect}
2014-10-03 09:24:37,578 261892068 DEBUG <  {id=39, error=402::Unknown client, successful=false, advice={interval=0, reconnect=handshake}, channel=/meta/connect}
2014-10-03 09:24:37,623 261892068 DEBUG >  {id=40, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0} null
2014-10-03 09:24:37,623 261892068 DEBUG >> {id=40, minimumVersion=0.9, supportedConnectionTypes=[long-polling, callback-polling], advice={timeout=60000, interval=0}, channel=/meta/handshake, version=1.0}
2014-10-03 09:24:37,642 261892068 DEBUG << {id=40, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=21jjt0xf69cxg3fxiastthza4d, version=1.0}
2014-10-03 09:24:37,643 261892068 DEBUG <  {id=40, minimumVersion=1.0, supportedConnectionTypes=[callback-polling, long-polling], successful=true, channel=/meta/handshake, clientId=21jjt0xf69cxg3fxiastthza4d, version=1.0}
2014-10-03 09:24:37,652 261892068 DEBUG >  {id=41, subscription=/stats, channel=/meta/subscribe, clientId=21jjt0xf69cxg3fxiastthza4d} 21jjt0xf69cxg3fxiastthza4d - last connect 0 ms ago
2014-10-03 09:24:37,652 261892068 DEBUG >> {id=41, subscription=/stats, channel=/meta/subscribe, clientId=21jjt0xf69cxg3fxiastthza4d}
2014-10-03 09:24:37,654 261892068 DEBUG No authorizers, CREATE for channel /stats granted
2014-10-03 09:24:37,654 261892068 DEBUG Added channel /stats
2014-10-03 09:24:37,654 261892068 DEBUG No authorizers, SUBSCRIBE for channel /stats granted
2014-10-03 09:24:37,655 261892068 DEBUG No authorizers, SUBSCRIBE for channel /stats granted
2014-10-03 09:24:37,655 261892068 DEBUG << {id=41, subscription=/stats, successful=true, channel=/meta/subscribe}
2014-10-03 09:24:37,655 261892068 DEBUG <  {id=41, subscription=/stats, successful=true, channel=/meta/subscribe}
2014-10-03 09:24:37,655 261892068 DEBUG >  {id=42, subscription=/msgs, channel=/meta/subscribe, clientId=21jjt0xf69cxg3fxiastthza4d} 21jjt0xf69cxg3fxiastthza4d - last connect 0 ms ago
2014-10-03 09:24:37,655 261892068 DEBUG >> {id=42, subscription=/msgs, channel=/meta/subscribe, clientId=21jjt0xf69cxg3fxiastthza4d}
2014-10-03 09:24:37,655 261892068 DEBUG No authorizers, CREATE for channel /msgs granted
2014-10-03 09:24:37,657 261892068 DEBUG Added channel /msgs
2014-10-03 09:24:37,657 261892068 DEBUG No authorizers, SUBSCRIBE for channel /msgs granted
2014-10-03 09:24:37,657 261892068 DEBUG No authorizers, SUBSCRIBE for channel /msgs granted
2014-10-03 09:24:37,657 261892068 DEBUG << {id=42, subscription=/msgs, successful=true, channel=/meta/subscribe}
2014-10-03 09:24:37,657 261892068 DEBUG <  {id=42, subscription=/msgs, successful=true, channel=/meta/subscribe}
2014-10-03 09:24:37,663 261892068 DEBUG >  {id=43, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d} 21jjt0xf69cxg3fxiastthza4d - last connect 0 ms ago
2014-10-03 09:24:37,663 261892068 DEBUG >> {id=43, connectionType=long-polling, advice={timeout=0}, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d}
2014-10-03 09:24:37,664 261892068 DEBUG << {id=43, successful=true, advice={interval=0, reconnect=retry, timeout=30000}, channel=/meta/connect}
2014-10-03 09:24:37,665 261892068 DEBUG <  {id=43, successful=true, advice={interval=0, reconnect=retry, timeout=30000}, channel=/meta/connect}
2014-10-03 09:24:37,694 261892068 DEBUG >  {id=44, connectionType=long-polling, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d} 21jjt0xf69cxg3fxiastthza4d - last connect 1 ms ago
2014-10-03 09:24:37,694 261892068 DEBUG >> {id=44, connectionType=long-polling, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d}
2014-10-03 09:24:37,694 261892068 DEBUG << {id=44, successful=true, channel=/meta/connect}
2014-10-03 09:24:43,046 261892068 DEBUG <  {id=1, data={contents=[nz.eftpos.internode.gui.web.model.Status@4f88102d, nz.eftpos.internode.gui.web.model.Status@6dde2325, nz.eftpos.internode.gui.web.model.Status@12d58a7d, nz.eftpos.internode.gui.web.model.Status@1771e34, nz.eftpos.internode.gui.web.model.Status@335fe8ac, nz.eftpos.internode.gui.web.model.Status@5da48e8d], type=statusUpdate}, channel=/stats}
2014-10-03 09:24:43,079 261892068 DEBUG <  {id=44, successful=true, channel=/meta/connect}
2014-10-03 09:24:43,097 261892068 DEBUG >  {id=45, connectionType=long-polling, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d} 21jjt0xf69cxg3fxiastthza4d - last connect 5385 ms ago
2014-10-03 09:24:43,097 261892068 DEBUG >> {id=45, connectionType=long-polling, channel=/meta/connect, clientId=21jjt0xf69cxg3fxiastthza4d}
2014-10-03 09:24:43,097 261892068 DEBUG << {id=45, successful=true, channel=/meta/connect}

0 个答案:

没有答案