Skip to content

Instantly share code, notes, and snippets.

@carsonmcdonald
Created April 27, 2011 14:52
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save carsonmcdonald/944386 to your computer and use it in GitHub Desktop.
Save carsonmcdonald/944386 to your computer and use it in GitHub Desktop.
How to set up ruby, eventmachine and spdy to use NPN
#
# Get development tools installed
#
sudo yum install -y git cvs zlib-devel
sudo yum groupinstall -y "Development Tools"
#
# Install RVM
#
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
. .rvm/scripts/rvm
#
# Compile OpenSSL that has NPN support
#
mkdir openssl
cd openssl
mkdir openssl-dist
cvs -d anonymous@cvs.openssl.org:/openssl-cvs co openssl
#or wget ftp://ftp.openssl.org/snapshot/openssl-SNAP-20110425.tar.gz; tar xvzf openssl-SNAP-20110425.tar.gz; mv openssl-SNAP-20110425 openssl-src
mv openssl openssl-src
cd openssl-src
./config --prefix=$HOME/openssl/openssl-dist/
make depend
make install
cd ..
#
# Set up the environment to point to the NPN OpenSSL
#
cat >> openssl-env.sh <<EOF
export PATH=$HOME/openssl/openssl-dist/bin/:$PATH
export LD_LIBRARY_PATH=$HOME/openssl/openssl-dist/lib
export PKG_CONFIG_PATH=$HOME/openssl/openssl-dist/lib/pkgconfig
export CPATH=$HOME/openssl/openssl-dist/include
EOF
. openssl-env.sh
cd ..
#
# RVM install 1.9.2 pointing it to the custom openssl version
#
# If you have 1.9.2 installed already remove it first: rvm remove 1.9.2
rvm install 1.9.2 -C --with-openssl-dir=$HOME/openssl/openssl-dist/
rvm use 1.9.2
#
# Install a handfull of gem deps needed later
#
gem install rake-compiler rspec bundler bindata ffi-zlib
#
# Install the NPN enabled event machine
#
git clone git://github.com/carsonmcdonald/eventmachine.git
cd eventmachine
git checkout tls-npn
rake gem
gem install pkg/eventmachine-1.0.0.beta.3.gem
cd ..
#
# Install spdy
#
git clone git://github.com/carsonmcdonald/spdy.git
cd spdy
git checkout npn
cd examples
ruby npn_spdy_server.rb
#
# You can now connect to the server on port 8000 using https. Using a browser without
# SPDY support you will see a non-spdy response and with support you will see a spdy
# response.
#
@robotarmy
Copy link

-fPIC needed on ubuntu

@TheRook
Copy link

TheRook commented Oct 28, 2011

After building on ubuntu 11.10 using:
./config --prefix=$HOME/local/ shared -fPIC
and
rvm install 1.9.2-p180 -C --with-openssl-dir=$HOME/local

I get the exact same error as the base project every time chrome connects:
[:SPDY, :connection_closed]

It doesn't matter if i use --use-spdy=ssl or --use-spdy=no-ssl

Did chrome change its spdy implementation? Is this project out of date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment