pnxtech / hydra

A light-weight library for building distributed applications such as microservices
https://www.hydramicroservice.com
MIT License
645 stars 54 forks source link

Proxying socket.io connection #171

Closed lukaszjanyga closed 6 years ago

lukaszjanyga commented 6 years ago

Hello everyone, I am looking for some advice on how to best handle proxying of socket connections. I am using the API Gateway pattern to expose a single point of entry. REST requests are forwarded using hydra.makeAPIRequest() and they call appropriate services.

I am struggling a bit with how to handle Socket.io connections, not to expose our Notification Service directly. There are some packages (socket.io-proxy) that offer this functionality but they require direct addressing while hydra operates on dynamic ports and instances.

What are your thoughts on the issue? How to best handle this case?

cjus commented 6 years ago

@alvarg93 Have you considered using HydraRouter which already has support for websocket message routing to microservices? In Hydra-router an incoming websocket call can be translated (automatically) to a REST call. https://www.hydramicroservice.com/docs/tools/hydra-router/

lukaszjanyga commented 6 years ago

I'll take a look, thanks 🙂

cjus commented 6 years ago

@alvarg93 let us know if you have further questions. Please close this ticket if not. ;-)