1

I create socket connection each time user logs into my application. This means if they open new tabs within same browser window multiple socket connections are established for each browser tabs. Problem occurs when I close these tabs; inconsistently /disconnect inbound service is called. This means for some connection /disconnect is not called and for some it is called. I can't reproduce this consistently (sometimes it called /disconnect sometimes it doesn't).

I am relying on /disconnect to clean up temporal objects created(stored in datastore) for a particular channel so I am left with all the OpenChannel objects for which /disconnect is never called.

This happens with Chrome and FireFox and never with IE. Am I using API correctly? Should there ever be one socket connection per browser window rather than tab? (If this is the case then if we store token in the cookie, do we re-establish connection with this token? Wouldn't this count as two connection per client id?

Thanks.

user_1357
  • 7,766
  • 13
  • 63
  • 106

1 Answers1

1

If you open more than two connections against a token created with the same client id, behavior becomes undefined. So if you're using, say, user.user_id() as the client id and the same user opens 3 tabs, you probably won't get the /disconnected callback for one of those tabs, even if you create new tokens for each of those tabs.

Moishe Lettvin
  • 8,462
  • 1
  • 26
  • 40
  • No, I am generating unique ids per conenction. This means each tab generates its own client id to establish a connection. So your comment is not the case. – user_1357 Feb 08 '12 at 20:57
  • Okay, good. How long are you waiting to receieve (or not) the disconnect notification? Sometimes it can take up to 10 minutes or so after the client's closed. – Moishe Lettvin Feb 08 '12 at 21:56
  • Thanks for the reply. Basically days, I have all the OpenChannel objects (created when channel is connected) for which disconnect is never called. – user_1357 Feb 08 '12 at 21:59
  • How often is this happening? I mean, is it once per 10000 channels, or more like once per 10? There's not an _absolute_ guarantee that you'll get the disconnect notification but not getting it should be very rare. – Moishe Lettvin Feb 08 '12 at 22:38
  • I tested with 3 consecutive channels within the same browser window (as separate tabs). I close tabs individually one of them never received /disconnect. But as I explained in above I cannot consistently reproduce the bug, but it does occur often. Bug seem to occur when there are multiple valid connections for each tabs and when you close them. Thanks. – user_1357 Feb 08 '12 at 23:03
  • Also we have approximately 70,000 connection objects (never received /disconnect) for approximately 2000 users, within a week and half so bug have to happen often. Thanks. – user_1357 Feb 08 '12 at 23:10
  • Thanks. I will add some logging to get more information on this. – user_1357 Feb 10 '12 at 03:21