Nodejs is a single process. The general method is to use a daemon process. As far as I know, there is a nodemon library that will be automatically opened when the machine is down. However, this method is not applicable to websockets. Even if the daemon process is restarted, the previous socket will be no longer available. It crashes. Although the server is guaranteed to be normal, it still affects the user experience. Should we try to catch all possible problems? If a third-party library is called in the socket, this method of plugging the loophole seems impossible to execute perfectly.
At this time, the client also needs to have a local cache of reconnection and key information. Other information that needs to be maintained can be cached on the server at any time