BOSH browser close timeout

Is there a way to make a user’s presence change instantly or very soon after they close the browser if they are connected with BOSH? Basically a faster session timeout or something?

You can send a to the BOSH endpoint manually onbeforeunload in the browser.

That sounds like a great solution! I tried it, and it works well. The only problem is that it does not seem to be working in chrome…Maybe the browser closes so fast that the information doesn’t get sent? I’m not sure. I can get an alert box to fire onbeforeload…BTW i’m using strophe.js…maybe that’s part of the problem…it’s too slow?

I believe that it has to do with how th HTTP request is handled when the page unloads. The request from strophe is already async, but I think that it doesn’t make it out of the browser before the page unloads.

What I’ve found is that you have two options:

  1. You can throw up a window.alert() right after you make the call to send the presence.

  2. You can modify strophe.js and add an async option when the AJAX call is made in strophe. I did this by adding a public property and set this to true only on the unload. I’ve found that this does seem to cause issues with IE8, but works fine in other browsers.