How to implement websocket-based push service through Rails?

1.4k Views Asked by At

I'm building a messaging app like WhatsApp. My goal is to expose only REST API through Rails and "push notifications" to connected clients via websockets. So clients communicate with server only with the REST API. Only the server sends data through the websocket. Clients can only receive data from it.

Currently I've built an eventmachine server listening for websocket connections and Unix domain socket connections. When a client performs a request on the REST API, Rails connects to the Unix domain socket to tell the eventmachine what connected client needs to be notified through the websocket.

My concern is about how it will behave in production (my server runs Apache Passenger). So I'm looking for some project to solve my problem. I had a look at Faye but I can't understand how to force it to send notifications to connected clients from an external process (that might be rails while is performing a request). Any ideas?

1

There are 1 best solutions below

0
On

Have you looked at the sync gem I am doing something similar and that is what i use

https://github.com/chrismccord/sync

They have a really good video on integration and a example https://github.com/chrismccord/sync_example

and this fully supports Faye and Pusher.

I use Faye for dev and Pusher for production