socketio / socket.io-admin-ui

Admin UI for Socket.IO
https://admin.socket.io
MIT License
358 stars 95 forks source link

Admin UI Not Showing All Servers #39

Closed heyFahad closed 2 years ago

heyFahad commented 2 years ago

Hello there,

I have implemented my Socket.io server using multiple nodes. My script starts 4 Socket.io servers at a time, and all these servers are connected via the MongoDB adapter. An Nginx server works as a reverse proxy between my servers and the users, and my clients are connecting to my server using the WebSocket transport because the Nginx sticky sessions never worked for me for whatever reason. Due to the shortage of time, I skipped setting up the sticky sessions at that moment and proceeded with only WebSocket transport.

One other thing worth mentioning here is that my local development server, and the production server, both are connected to the same capped collection of MongoDB for listening to the adapter events.

Now the problem is, whenever I try to connect Admin UI with my Socket.io server, it connects successfully. But it only shows me stats for that one specific instance of Socket.io server with which Admin UI is connected. To my surprise, I see my local development (Socket.io) server, when it is running locally, listed in the list of servers. Although I connect my Admin UI specifically with the URL of my production app URL.

Can you please help me figure out what is happening here? Why my all production servers are not being listed in Admin UI, and why am I seeing my local dev server in the list of production servers?

darrachequesne commented 2 years ago

You might need to customize the serverId attribute of the server: https://socket.io/docs/v4/admin-ui/#serverid

Regarding your dev server, I don't think this is a good idea to use the same collection for both environments.

heyFahad commented 2 years ago

Hey, thanks for the tip @darrachequesne. It worked by just adding this serverId attribute. Now one other concern is this:

Socket-IO-Admin-UI

As you can see, both of my servers have the same number of clients. When I looked at the list of connected sockets, I had sockets connecting from the same IPs:

Socket-IO-Admin-UI

Does this mean that all of my clients are connected with all the available servers? I'm using the websocket transport to connect to my server.

darrachequesne commented 2 years ago

If I recall correctly Nginx load-balances the requests in a round-robin fashion by default, so that should explain the fact that there is more or less the same number of clients on all servers.

Regarding the duplicate IPs, maybe some users have multiple browser tabs (one WebSocket connection per tab)?

darrachequesne commented 2 years ago

Closed due to inactivity, please reopen if needed.