Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#9433 closed defect (fixed)

dojox.cometd.disconnect does not always fire on page unload

Reported by: Bertrand Fan Owned by: Greg Wilkins
Priority: high Milestone: 1.7
Component: DojoX Cometd Version: 1.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

This is described here but the gist of it is that when comet is doing long-polling, the disconnect doesn't always complete when the page unloads. From my testing, when you close the window the xHr will fire but if you click on a link, it may or may not fire but it will not complete the disconnect.

The solution given is to do a synchronous xHr and this does indeed work, so I think this should probably be put into the longPollTransport code.

Here's the fix that I'm using:

        dojo.addOnUnload(function() {

            var transport = dojox.cometd.currentTransport;

    		var message = {
    			channel: "/meta/disconnect",
    			clientId: transport._cometd.clientId,
    			id:	"" + transport._cometd.messageId++
    		};
    		
    		dojo.xhrPost({
    		    postData: dojo.toJson([message]),
    		    headers: {
    		        'Content-Type': 'text/json;charset=UTF-8'
    		    },
    		    url: transport._cometd.url,
    		    handleAs: transport._cometd.handleAs,
    		    sync: true 
    		});
    		
            dojox.cometd.disconnect();

        });

but we can easily work add this into the disconnect function of longPollTransportJsonEncoded.js

Change History (5)

comment:1 Changed 10 years ago by Adam Peller

Component: GeneralDojoX Cometd
Owner: changed from anonymous to Greg Wilkins

comment:2 Changed 10 years ago by dante

Milestone: tbdfuture

comment:3 Changed 9 years ago by Chris Mitchell

Resolution: wontfix

closing as wontfix, as cometd client is now maintained at cometd.org. query will be sent to cometd team/Simone Bordet for review by cometd project leads

comment:4 Changed 9 years ago by dylan

Resolution: wontfixfixed
Status: newclosed

That is more related to a browser's behavior (e.g. some browsera do not allow XHR activity from unload handlers).

Cometd project does support synchronous disconnect, though, for browsers that allow XHR activity from unload handlers.

comment:5 Changed 9 years ago by bill

Milestone: future1.7
Note: See TracTickets for help on using tickets.