Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

does socket.io server need to be seperate from backend when deploying?

I am building react app. I have my client folder, and my backend folder that contains all my mongo db models, routes, functions etc…

I know realize that my app needs to use socket.io

My frontend is on localhost:3000 and my backend is on localhost:5000

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My understanding is that socket.io needs its own port.

Does this mean when I deploy to heroku I need to deploy a backend server, frontend server, and a socket.io server?

>Solution :

My understanding is that socket.io needs its own port.

This is incorrect. socket.io can use the same port as your backend just fine. Incoming requests to create a socket.io connection can be distinguished from other web requests via a custom header that the underlying webSocket connection protocol uses. This allows socket.io/webSocket and your http server to use the exact same port.

Does this mean when I deploy to heroku I need to deploy a backend server, frontend server, and a socket.io server?

No. You can still just have frontend server and backend server and the backend server can handle both your backend requests and the socket.io connections.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading