Rails using Websockets with Nginx and Unicorn?

I am considering introducing chess (which requires web ports) with Rails and in a production deployment using Nginx as a reverse proxy to combine Unicorn processes.

In thinking about how to make this work, I asked the following questions:

As I understand it, websockets are a persistent connection. Since everything goes through the Nginx reverse proxy, how exactly does Unicorn workflow support connecting to a web server with a client browser? Will Nginx maintain a state in which the unicorn process of each browser website connects and acts as a kind of intermediary? Does the unicorn process keep you connected to the web throughout the workflow?

Is there a recommended way to implement chess (with websockets) using Rails?

+7
source share
2 answers

Connecting Unicorn synchronous processing with asynchronous delivery using nginx would imply some logic on the nginx side, which seems at least inconvenient to me. Maximum is impossible.

There is a Railscast about Private Pub Stone, which uses a thin web server. It is more suitable for this task: it is asynchronous, it is able to process many concurrent requests using event-based input-output. Therefore, I suggest you replace Unicorn Thin or install Thin side by side.

Puma's web server may also be an option, however I cannot provide more information about this.

+1
source

nginx will not do web ports. Are you sure you cannot do this with AJAX? If you really need the ability to click, you can try something built around the Comet approach: http://en.wikipedia.org/wiki/Comet_(programming)

Faye is a pretty good stone for implementing a comet on rails: http://faye.jcoglan.com/

-4
source

All Articles