I have a socket connection between my server which is running in AWS ASG group with EC2 instances and frontend portal running separately. Now the problem is the socket connection disconnect when the any instance downscale and then reconnects to some other instance immediately due to socket reconnection mechanism. Now the problem is I have to update some fields of the user if the socket disconnection is initiated by the user in the frontend portal and basically I was listening to ‘ disconnect ‘ event in backend for that. But now when the instance downscale the same fields are updated, which I want to prevent.
I went through the disconnect reasons in socket.io documentation and felt that instance downscaling may come under the disconnect reason as ‘server shutting down’ but when I tested it the reason came to be ‘transport close’ which is the same reason when the tab is closed in frontend and therefore I am not able to differentiate between the two cases.