user2503648
user2503648

Reputation: 17

socket io connect to private ip / private subnet in vpc

My goal is to socket io connect from my public server to my private server via const socket = io("10.0.2.50:3001") both of which are connected to my vpc. the private server has the socket/server code for my app, the public server displays the front end. I would like users to be able to link to/connect to other private servers on the private subnet.

i have a basic aws vpc setup -

What is working -

My feeling is that connecting to a private server in a vpc is a socket io limitation, but i'm not sure why that would be the case and was curious if there's a workaround.

Thanks in advance

Upvotes: 0

Views: 277

Answers (1)

Mark B
Mark B

Reputation: 200790

"My feeling is that connecting to a private server in a vpc is a socket io limitation"

No, it is just how networks work. Your front-end code runs in the web browser on your laptop, not in the VPC. Your laptop is not inside the VPC. Your laptop can only connect to public resources in your VPC, it can not connect to private resources in your VPC. That is the very definition of public and private VPC resources.

For Socket.IO connections to work between web browsers on the public Internet and your back-end servers, those servers must be in a public subnet and have a public IP address, or the traffic must be proxied through either a public server or a public load balancer.

Upvotes: 2

Related Questions