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

Time:12-01

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

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?

CodePudding user response:

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.

  • Related