How to expose multiple ports from Web Service

Hi!

I am running my API as a Web Service on Render and that works really well.

Now I want for clients to be able to connect to a Websocket that is exposed by this API. Is there any way to do this? I read that it is only possible to expose 1 port? Then Websocket API and general API need to be separate and can not be together? That would suck massively actually.

If anyone knows with certainty and/or has a way around it, please tell.

Thanks
Michel

By the way, I use Node.js with Express.

Hi,

You can’t expose multiple ports to the public internet, as you found. Covered in the docs here: https://docs.render.com/web-services#binding-to-multiple-ports

If you want them on the same service you’d need to integrate your Websockets into the web server, e.g. sockets.io has an example of integrating with Express: https://socket.io/get-started/chat#integrating-socketio

Alan

1 Like

Oh wow, I didn’t know that this is possible, thank you so much Alan!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.