Is it possible to use Rails with Phoenix?


just a quick question - is it wise/possible to mix phoenix websockets support into existing rails application? Rails websocketa are ‘slow’ when compared with elixir/phoenix, however rewriting whole app is not possible. That’s why idea of just adding websockets via elixir/phoenix.

What do you think?

1 Like

It is definitely a viable approach. How are you planning to communicate between the elixir and rails apps?

I did this with rails 4 and instead of phoenix used node.js with and redis pub/sub. I used to push events to redis from the rails app and the node.js app would just read these events and send it to the connected sockets.

1 Like

Initial idea was to use redis or rabbitmq and then perhaps elixir/phoenix to manage websockets.

Was it complicated in your case?

Mine was a simple use case of streaming the logs of a CI system. So it was very straight forward. Redis/RabittMQ should do the job. You’ll also need to think of a strategy to do authentication if your websocket connections need them. Overall, it shouldn’t be very difficult.

It may also be possible for your rails code to act as a Phoenix channel client and send messages to Phoenix which would then broadcast it as necessary removing the need for redis or rabbitmq. However, I am not sure if that is a good strategy.