Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsubscribeUrl does not invoke X-Atmosphere-Transport=close for enableProtocol=true and resource is not removed from broadcaster #928

Closed
oyvindhorneland opened this issue Feb 22, 2013 · 4 comments

Comments

@oyvindhorneland
Copy link

Hi,

Regarding unsubscribeUrl in https://github.com/Atmosphere/atmosphere/blob/atmosphere-1.0.x/modules/jquery/src/main/webapp/jquery/jquery.atmosphere.js

I tried a scenario where I managed multiple request resources from the client. To be able to unsubscribe a specific request, I had to use unsubscribeUrl because unsubscribe would close both requests.

During these tests, I observed that unsubscribe had
if (rq.enableProtocol()) {
jQuery.ajax({url: rq.getUrl() + "?X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=" + rq.getUUID(), async:false});
}
while unsubscribeUrl had no such close call.

The server detected connection close if I used unsubscribe, but not if I used unsubscribeUrl. The server would also detect connection close if I simply closed the browser.

I've tested with the same addition to unsubscribeUrl and it works well.

The X-Atmosphere-Transport=close request sent to my servlet can not be used to remove resource from broadcaster. While the uuid is the same, the request object received in the servlet is not. Calling broadcaster.removeAtmosphereResource(resource) will try to remove a matching object and since the object can't be found nothing is removed. if i iterate through broadcaster.getAtmosphereResources(), match the uuids and call broadcaster.removeAtmosphereResource(resource) on the resource found everything works as expected.

Setup:

  • Atmosphere 1.0.10
  • Jetty 8.1
  • Based on atmosphere-atmospherehandler-pubsub
  • request.enableProtocol=true
  • Broadcaster: DefaultBroadcaster
  • Cache: UUIDBroadcasterCache

Regards,
Øyvind

@jfarcand
Copy link
Member

Salut,

my idea here was to not send the close protocol because it would tell Atmosphere that the client has completely disappeared. But I kind of agree with you it would be useful to have such mechanism. So I will add support in 1.1 as I don't know yet if I will release a 1.0.12. As a workaround, you can implement the mechanism inside the onClose function by calling

jQuery.ajax({url: response.request.url 
    + "?X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=" 
    + response.request.uuid, async:false});

@oyvindhorneland
Copy link
Author

Hi,

Workaround tested OK! Thanks!

Any thoughts about not being able to remove the AtmosphereResource from the broadcaster during the X-Atmosphere-Transport=close request without iterating though them all and mathing uuids?

Øyvind

@jfarcand
Copy link
Member

AtmosphereResourceFactory.getDefault().remove(uuid);

@oyvindhorneland
Copy link
Author

Ah. Thanks!

jfarcand added a commit that referenced this issue Feb 27, 2013
jfarcand added a commit that referenced this issue Feb 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants