Opening a new WebSocket for each client sounds like a lot of stress on the server, do you need the persistent connection? What if the client visits a new page? A new connection is created?
1. To get the total online active users.
2. Is to log the total active time on the webpage when user leave’s.
Any other way that you suggest?