https://github.com/phusion/passenger-ruby-faye-websocket-demo
Demonstrates WebSockets on Phusion Passenger through the faye-websocket gem
https://github.com/phusion/passenger-ruby-faye-websocket-demo
Last synced: about 1 year ago
JSON representation
Demonstrates WebSockets on Phusion Passenger through the faye-websocket gem
- Host: GitHub
- URL: https://github.com/phusion/passenger-ruby-faye-websocket-demo
- Owner: phusion
- Created: 2014-05-28T20:14:54.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-12-07T18:48:30.000Z (over 10 years ago)
- Last Synced: 2023-04-09T13:16:09.284Z (about 3 years ago)
- Language: CSS
- Size: 47.9 KB
- Stars: 3
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Phusion Passenger: Faye WebSocket demo
This application demonstrates WebSocket support in [the Phusion Passenger application server for Ruby](https://www.phusionpassenger.com/), through the use of the awesome [faye-websocket gem](https://github.com/faye/faye-websocket-ruby). Passenger supports all major modern web technologies, such as WebSockets, entirely out of the box. You don't have to do anything: WebSocket support just works.
If you like this demo, please [tweet about it](https://twitter.com/share) or [follow us on Twitter](https://twitter.com/phusion_nl).
**Table of contents**
* [Getting started](#getting_started)
* [Running the demo in Passenger Standalone](#running_standalone)
* [Running the demo in Passenger for Nginx](#running_nginx)
* [Running the demo in Passenger for Apache](#running_apache)
* [Notes](#notes)
* [Tuning](#tuning)
* [Multithreading not required](#multithreading_not_required)
* [Non-Faye demo](#non_faye_demo)
* [Next steps](#next_steps)
* [About Phusion Passenger](#about)

-------------------------------------------------------
1. [Install Phusion Passenger](https://www.phusionpassenger.com/) 4.0.43 or later.
2. Clone this repository:
git clone https://github.com/phusion/passenger-ruby-faye-websocket-demo.git
cd passenger-ruby-faye-websocket-demo
3. Install dependencies:
bundle install
### Running the demo in Passenger Standalone
Run:
passenger start
Access the demo application at http://0.0.0.0:3000/ and see it in action.
### Running the demo in Passenger for Nginx
Create a virtual host in your Nginx configuration file:
server {
listen 3000;
server_name passenger-ruby-faye-websocket.demo;
root /path-to/passenger-ruby-faye-websocket-demo/public;
passenger_enabled on;
}
Add `passenger-ruby-faye-websocket.demo` to your `/etc/hosts`:
echo 127.0.0.1 passenger-ruby-faye-websocket.demo | sudo tee -a /etc/hosts
Then restart Nginx, and access the demo application at http://passenger-ruby-faye-websocket.demo:3000/
### Running the demo in Passenger for Apache
Apache itself doesn't work very well with WebSockets, so running in Apache is not recommended.
Create a virtual host in your Apache configuration file:
# Comment out if you already have a "Listen 3000" directive somewhere.
Listen 3000
# Comment out when using Apache >= 2.4.
NameVirtualHost *:3000
ServerName passenger-ruby-faye-websocket.demo
DocumentRoot /path-to/passenger-ruby-faye-websocket-demo/public
Add `passenger-ruby-faye-websocket.demo` to your `/etc/hosts`:
echo 127.0.0.1 passenger-ruby-faye-websocket.demo | sudo tee -a /etc/hosts
Then restart Apache, and access the demo application at http://passenger-ruby-faye-websocket.demo:3000/
You may have to [tune Passenger for optimal Websocket performance](https://www.phusionpassenger.com/library/config/tuning_sse_and_websockets/).
### Multithreading not required
WebSockets work great on both the open source variant of Phusion Passenger, as well as on [Phusion Passenger Enterprise](https://www.phusionpassenger.com/). Multithreading is *not* required for faye-websocket to work optimally, because faye-websocket uses EventMachine to serve WebSockets.
There is also a Phusion Passenger + WebSocket demo that does not use the faye-websocket gem: https://github.com/phusion/passenger-ruby-websocket-demo. That demo is implemented using pure Rack and a low-level WebSocket parser library, showing you how things might work if you use WebSockets through a different gem.
* Using WebSockets on Phusion Passenger? [Tweet about us](https://twitter.com/share), [follow us on Twitter](https://twitter.com/phusion_nl) or [fork us on Github](https://github.com/phusion/passenger).
* Having problems? Please post a message at [the community discussion forum](https://groups.google.com/d/forum/phusion-passenger).
[
](http://www.phusion.nl/)
Please enjoy Phusion Passenger, a product by [Phusion](http://www.phusion.nl/). :-)

Phusion Passenger used in Game of Thrones Ascention
[Phusion Passengerâ„¢](https://www.phusionpassenger.com/) is a web server and application server, designed to be fast, robust and lightweight. It takes a lot of complexity out of deploying web apps, adds powerful enterprise-grade features that are useful in production, and makes administration much easier and less complex. Phusion Passenger supports Ruby, Python, Node.js and Meteor, and is being used by high-profile companies such as **Apple, Pixar, New York Times, AirBnB, Juniper** etc as well as [over 350.000 websites](http://trends.builtwith.com/Web-Server/Phusion-Passenger).
**Learn more:** [Website](https://www.phusionpassenger.com/) | [Documentation](https://www.phusionpassenger.com/library/) | [Support resources](https://www.phusionpassenger.com/documentation_and_support) | [Github](https://github.com/phusion/passenger) | [Twitter](https://twitter.com/phusion_nl) | [Blog](http://blog.phusion.nl/)