I have deployed my react app to Heroku and also the socket server. Heroku assigns a different port every time than how I can set it in react app.
ex. for localhost: im setting socket server post 8900 and in react app, im using - socket.current = io("ws://localhost:8900");
I'm using Heroku's free tier. And if the server is idle for 30 mins then it will be automatically going offline. When it gets a new req, it starts again but with a different port assigned by Heroku. So, I guess in the free tier, we can't host a socket server in Heroku's free tier as its port will be changed every time it restarts.