On connect is being called twice

54 views
Skip to first unread message

vineet

unread,
Apr 16, 2012, 7:26:19 AM4/16/12
to no...@googlegroups.com
Hi

I am observing some problematic behavior with NowsJS on connect call.

nowjs.on("connect"), calls itself 2-3 times each time I connect to the server. I also checked out the this.user object. Its contains two different clientId's. 

Did someone run into this before?

vineet

unread,
Apr 16, 2012, 7:54:21 AM4/16/12
to no...@googlegroups.com
I would like to add. I am facing this problem on Chromium browser, Ubuntu. When using Firefox under same circumstances, things work fine, call happens multiple times, at least the clientId is same.

Paul Aan

unread,
Apr 16, 2012, 8:40:03 AM4/16/12
to no...@googlegroups.com
You have to show off your code over here to see in detail.
--
Hoài Ân
Skype: mrgluexv
0903744334


Ian Serlin

unread,
Apr 17, 2012, 2:06:47 AM4/17/12
to no...@googlegroups.com
Hi Vineet,

If you can post a version of your code that exhibits this behavior I could look into it more.

Thanks!

Vineet Markan

unread,
Apr 17, 2012, 3:14:03 AM4/17/12
to no...@googlegroups.com
Hi Ian.Paul

Thanks for acknowledging, but I spent some time and figured it out. I would just document it here in case anyone runs into this. The problem was actually with layout.jade from Express framework, the default behavior is to include all contents of index.jade into the body of rendered page, so nowjs was being included twice while it showed up only once in the head tag and once in the body(which I never bothered to check). Though Firefox ignored this, Chrome went ahead and established more than one connections thus nowjs.on("connect") was being called twice. 

But an interesting discovery here is that a new clientId is assigned to the same user, lets say if I were to open a new tab for my app, will this behavior persist or is it possible to identify this client as already connected? 

Sorry for the false alarm, btw.

Vineet Markan
Framebench

Ian Serlin

unread,
Apr 17, 2012, 11:34:37 AM4/17/12
to no...@googlegroups.com
Hi Vineet,

Glad it got figured out!

As far as the new tabs go, you would need to use some kind of secondary identification to know the same user in multiple tabs was actually the same user, regular HTTP session cookies would work for this (which is built into express as an option).

Vineet Markan

unread,
Apr 18, 2012, 1:32:16 AM4/18/12
to no...@googlegroups.com
Thanks Ian. Will check it out.

Vineet Markan
Framebench
Reply all
Reply to author
Forward
0 new messages