[Node JS] Number of connections/subscribers are too high as compared to unique channels

38 views
Skip to first unread message

san...@jugnoo.in

unread,
Jul 2, 2017, 1:39:15 PM7/2/17
to Faye users
I have created an app where user (from android/ios app) chats with an agent (web). A unique channel is created for each end user. Agents subscribes to same channel.

I noticed that number of subscriber and connections active are a lot higher than unique channels subscribed. Here is the sample numbers:
new connection, SIZE:  757
new subscription, SIZE:  766 
add channel, Unique channels:  62

Thats 10 times. Ideally it should be max 2x. One possible reason could be that client side is generating different client IDs and making a new connections while old one still active. This is resulting in continuously increasing server memory usage and network usage. I have to restart node process every few hours.

How do I debug it? Any help would be appreciated. How do I know which ones are actually active and how do I disconnect it from server side.



Here is how I am counting the number of subscribers/connections/channels. 
//Faye Listeners
bayeux.on('handshake', function (clientId) {
connectUser(clientId)
});

bayeux.on('subscribe', function (clientId, channel) {
subscribeUser(clientId+", "+channel)
addChannel(channel);
});



bayeux.on('unsubscribe', function (clientId, channel) {
unsubscribeUser(clientId+", "+channel);
removeChannel(channel);
});

bayeux.on('disconnect', function (clientId) {
disconnectUser(clientId)
});
Reply all
Reply to author
Forward
0 new messages