I am using NestJS to create my websocket server using the ws library on WSL2. Here are the following steps to reproduce my issue:
- I run my HTTP server with
nest start - I connect to the ws instance using Postman
- I shut down the server process in my terminal with "Ctrl + C"
- Postman says I'm still connected to the server
If I run the server again, I get a Error: listen EADDRINUSE: address already in use :::3000 which requires me to manually kill the process.
I can also disconnect from postman and then I'll be able to start the server again. This seems really weird to me and I don't remember this happening when working with a regular Express app ws server.
I guess I should be terminating all client connections when the server is closed, but I thought this was supposed to automatically happen. Am I missing something here?
Edit: I tried building my NestJS app and ran node main.js in my /dist directory. And now it's properly handling disconnecting all clients when closing the server. Issues seems to be related to using the nest cli?