Showing posts with label eventmachine. Show all posts
Showing posts with label eventmachine. Show all posts

Sunday, May 15, 2011

Finally 64 bit Ruby SPDY

‹prev | My Chain | next›

Up today, I hope to verify that I have put behind my 64 bit woes behind for good. Specifically, I hope that yesterday's magical configuration settings for openssl will translate into a working TLS/NPN enabled eventmachine—more specifically Carson McDonald's tls-npn fork.

So, back in my local copy of the tls-npn fork, I try to install the gem:
➜  eventmachine git:(tls-npn) gem install pkg/eventmachine-1.0.0.beta.3.gem
Building native extensions. This could take a while...
Successfully installed eventmachine-1.0.0.beta.3
1 gem installed
Wow. More than a bit anti-climatic. Surely it can't just work.

It doesn't.

It starts OK, but accessing the server results in:
➜  examples git:(master) ✗ ruby npn_spdy_server.rb                                     
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:404:in `set_negotiable_protocols': undefined method `set_negotiable_protocols' for EventMachine:Module (NoMethodError)
from npn_spdy_server.rb:35:in `post_init'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:45:in `block in new'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:36:in `instance_eval'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:36:in `new'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1415:in `event_callback'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run_machine'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run'
from npn_spdy_server.rb:66:in `<main>'
Hrm... aw nuts. I forgot to rebuild ruby with the new openssl install:
rvm remove 1.9.2
rvm install 1.9.2 -C --with-openssl-dir=$HOME/local
I reinstall the packages needed for the SPDY gem and eventmachine:
gem install rake-compiler rspec bundler bindata ffi-zlib
Finally, I fire up the sample npn_spdy_server from Carson McDonald, and access it with a web browser:
➜  examples git:(master) ✗ ruby npn_spdy_server.rb
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:414: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

-- control frame ----------
c:0009 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :get_negotiated_protocol
c:0008 p:0020 s:0025 b:0025 l:000024 d:000024 METHOD /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:414
c:0007 p:0011 s:0022 b:0022 l:000021 d:000021 METHOD npn_spdy_server.rb:41
c:0006 p:---- s:0018 b:0018 l:000017 d:000017 FINISH
c:0005 p:---- s:0016 b:0016 l:000015 d:000015 CFUNC :run_machine
c:0004 p:0248 s:0013 b:0013 l:000012 d:000012 METHOD /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206
c:0003 p:0070 s:0006 b:0006 l:0013d8 d:000c58 EVAL npn_spdy_server.rb:66
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0013d8 d:0013d8 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
npn_spdy_server.rb:66:in `<main>'
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run'
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run_machine'
npn_spdy_server.rb:41:in `ssl_handshake_completed'
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:414:in `get_negotiated_protocol'
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:414:in `get_negotiated_protocol'

-- C level backtrace information -------------------------------------------
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_vm_bugreport+0x5f) [0x7fb4cce97ebf]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x5fc7e) [0x7fb4ccd77c7e]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_bug+0xa2) [0x7fb4ccd78ba2]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x1132d5) [0x7fb4cce2b2d5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc60) [0x7fb4ccb09c60]
/lib/x86_64-linux-gnu/libc.so.6(memcpy+0xa0) [0x7fb4cbf26a00]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x11ff7f) [0x7fb4cce37f7f]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(+0x1c774) [0x7fb4cb4dc774]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x179cee) [0x7fb4cce91cee]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x16f816) [0x7fb4cce87816]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x175c53) [0x7fb4cce8dc53]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x176ef4) [0x7fb4cce8eef4]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_funcall+0xc2) [0x7fb4cce8fb32]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(+0x1d4ac) [0x7fb4cb4dd4ac]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(_ZN20ConnectionDescriptor20_DispatchInboundDataEPKci+0x83) [0x7fb4cb4d2fb3]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(_ZN20ConnectionDescriptor4ReadEv+0x9c) [0x7fb4cb4d309c]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(_ZN14EventMachine_t14_RunSelectOnceEv+0x2da) [0x7fb4cb4d6aba]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(_ZN14EventMachine_t8_RunOnceEv+0x28) [0x7fb4cb4d7c88]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(_ZN14EventMachine_t3RunEv+0x5c) [0x7fb4cb4d9a8c]
/home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so(+0x1c9e9) [0x7fb4cb4dc9e9]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x179cee) [0x7fb4cce91cee]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x16f816) [0x7fb4cce87816]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x175c53) [0x7fb4cce8dc53]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_iseq_eval_main+0xb1) [0x7fb4cce931c1]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(+0x660ba) [0x7fb4ccd7e0ba]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7fb4ccd7f01d]
/home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7fb4ccd8122e]
ruby(main+0x4b) [0x40094b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xff) [0x7fb4cbebaeff]
ruby() [0x400839]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

[1] 16613 abort ruby npn_spdy_server.rb
Holy cow.

Just when I think I have this all sorted out. Wow.

It turns out that, despite removing and rebuilding ruby with my local openssl libraries, ruby and eventmachine still do not know about the local openssl libraries:
1.9.2@spdy ~/repos/spdy/examples (master)$ ldd /home/cstrom/.rvm/gems/ruby-1.9.2-p0@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so
linux-vdso.so.1 => (0x00007fff363ff000)
libruby.so.1.9 => /home/cstrom/.rvm/rubies/ruby-1.9.2-p0/lib/libruby.so.1.9 (0x00007f1831b40000)
libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f18318c7000)
libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f1831537000)

libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1831319000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1831111000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1830f0c000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f1830cd3000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f18309cd000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1830747000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f18303b3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f183019d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1832188000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f182ff84000)
Bah!

My next step is to upgrade RVM rvm to the latest released version. This allows me to install ruby 1.9.2-p180 instead of the 1.9.2-p0 I had been using. With that, I re-run through the entire install procedure:
export PATH=$HOME/local/bin/:$PATH
export LD_LIBRARY_PATH=$HOME/local/lib
export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
export CPATH=$HOME/local/include

rvm install 1.9.2 -C --with-openssl-dir=$HOME/local
rvm use ruby-1.9.2-p180
rvm --default use 1.9.2-p180
rvm gemset create spdy
gem install rake-compiler rspec bundler bindata ffi-zlib

cd ~/repos/eventmachine/
rake clean
rake gem
gem install pkg/eventmachine-1.0.0.beta.3.gem
With that, I finally have an eventmachine linked against my local, npn-enabled openssl libraries:
1.9.2@spdy ~/repos/spdy/examples (master)$ ldd /home/cstrom/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/rubyeventmachine.so
linux-vdso.so.1 => (0x00007fffb0bef000)
libruby.so.1.9 => /home/cstrom/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9 (0x00007fe8e8c4d000)
libssl.so.1.1.0 => /home/cstrom/local/lib/libssl.so.1.1.0 (0x00007fe8e89ea000)
libcrypto.so.1.1.0 => /home/cstrom/local/lib/libcrypto.so.1.1.0 (0x00007fe8e8620000)

libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe8e83f6000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe8e81de000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe8e7fbf000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe8e7db7000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fe8e7b7e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe8e7877000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe8e75f2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe8e725e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe8e7047000)
Finally, I retry the npn_spdy_server:
1.9.2@spdy ~/repos/spdy/examples (master)$ ruby npn_spdy_server.rb 
[:SPDY, :connection_closed]
[:SPDY, :connection_closed]
[:SPDY, :connection_closed]
[:SPDY_HEADERS, {"accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "accept-charset"=>"ISO-8859-1,utf-8;q=0.7,*;q=0.3", "accept-encoding"=>"gzip,deflate,sdch", "accept-language"=>"en-US,en;q=0.8", "host"=>"localhost:10000", "method"=>"GET", "scheme"=>"https", "url"=>"/", "user-agent"=>"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.35 (KHTML, like Gecko) Chrome/13.0.761.0 Safari/534.35", "version"=>"HTTP/1.1"}]
[:SPDY, :sent, :SYN_REPLY]
[:SPDY, :sent, :DATA]
[:SPDY, :sent, :DATA_FIN]
[:SPDY, :connection_closed]
/home/cstrom/repos/spdy/lib/spdy/compressor.rb:35:in `inflate': invalid stream (RuntimeError)
from /home/cstrom/repos/spdy/lib/spdy/parser.rb:33:in `unpack_control'
from /home/cstrom/repos/spdy/lib/spdy/parser.rb:57:in `try_parse'
from /home/cstrom/repos/spdy/lib/spdy/parser.rb:11:in `<<'
from npn_spdy_server.rb:47:in `receive_data'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run_machine'
from /home/cstrom/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run'
from npn_spdy_server.rb:66:in `<main>'
Yay! Never have I been so glad to see an error message. Because, it the browser, I see:



The error message is solved in node.js, but still need to fix it here in ruby. Another day.


Day #21

Monday, May 2, 2011

Real SPDY with Eventmachine

‹prev | My Chain | next›

After an unsuccessful attempt last night, I hope to build on what I learned to get NPN SPDY working with eventmachine today. My ultimate hope is that this will allow me to build SPDY services without needing to run Chrome with the --with-spdy=ssl option (which seems to break things).

I eventually dead ended with a 64-bit openssl issue yesterday, so today I start by firing up my 32-bit Ubuntu 10.10 VM. I have yet to do much beyond installing build-essentials on that machine, so this should prove a fairly exhaustive step-by-step for getting going on Ubuntu.

Note: it was so new that I needed to install ssh, curl, git-core, and rvm.

On the VM, I stick with ruby 1.9.2 under rvm (somehow I started with 1.8.7 as my default on my laptop), and git clone the gem:
chris@chris-VirtualBox:~/repos$ git clone git://github.com/igrigorik/spdy.git
Initialized empty Git repository in /home/chris/repos/spdy/.git/
remote: Counting objects: 275, done.
remote: Compressing objects: 100% (167/167), done.
remote: Total 275 (delta 150), reused 177 (delta 93)
Receiving objects: 100% (275/275), 32.16 KiB, done.
Resolving deltas: 100% (150/150), done.
With that, I am ready to pick back up from where I left off yesterday. Specifically, I follow along with Carson McDonald's instructions.

First, I sudo apt-get install zlib1g-dev, which is the equivalent to the Fedora zlib-devel listed in Carson's instructions. The strange next step is to install cvs (way to keep up with the times, openssl), after which I can:
chris@chris-VirtualBox:~/repos$ cvs -d anonymous@cvs.openssl.org:/openssl-cvs co openssl
The authenticity of host 'cvs.openssl.org (194.97.152.144)' can't be established.
RSA key fingerprint is 55:c1:16:04:82:09:3a:ac:88:14:27:3f:46:7c:25:e4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'cvs.openssl.org,194.97.152.144' (RSA) to the list of known hosts.
cvs server: WARNING: Read-only repository access mode selected via `cvs -R'.
Using this option to access a repository which some users write to may
cause intermittent sandbox corruption.
cvs checkout: Updating openssl
U openssl/.cvsignore
U openssl/ACKNOWLEDGMENTS
...
U openssl/util/pl/ultrix.pl
U openssl/util/pl/unix.pl
Next, I configure openssl to install into $HOME/local, which is where I like to install custom built binaries that would normally install into /usr/bin or /usr/local/bin:
chris@chris-VirtualBox:~/repos/openssl$ ./config --prefix=$HOME/local
Operating system: i686-whatever-linux2
Configuring for linux-elf
Configuring for linux-elf
no-ec-nistp224-64-gcc-128 [default] OPENSSL_NO_EC_NISTP224_64_GCC_128 (skip dir)
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir)
no-shared [default]
no-store [experimental] OPENSSL_NO_STORE (skip dir)
no-zlib [default]
no-zlib-dynamic [default]
IsMK1MF=0
...
make[1]: Leaving directory `/home/chris/repos/openssl/test'

Since you've disabled or enabled at least one algorithm, you need to do
the following before building:

make depend

Configured for linux-elf.
With that, I can make depend:
chris@chris-VirtualBox:~/repos/openssl$ make depend
making depend in crypto...
make[1]: Entering directory `/home/chris/repos/openssl/crypto'
making depend in crypto/objects...
make[2]: Entering directory `/home/chris/repos/openssl/crypto/objects'
...
making depend in tools...
make[1]: Entering directory `/home/chris/repos/openssl/tools'
make[1]: Nothing to be done for `depend'.
make[1]: Leaving directory `/home/chris/repos/openssl/tools'
And make install:
chris@chris-VirtualBox:~/repos/openssl$ make install
...
installing libcrypto.a
installing libssl.a
cp libcrypto.pc /home/chris/local/lib/pkgconfig
chmod 644 /home/chris/local/lib/pkgconfig/libcrypto.pc
cp libssl.pc /home/chris/local/lib/pkgconfig
chmod 644 /home/chris/local/lib/pkgconfig/libssl.pc
cp openssl.pc /home/chris/local/lib/pkgconfig
chmod 644 /home/chris/local/lib/pkgconfig/openssl.pc
With openssl (hopefully) compiled OK, I add the $HOME/local directory to various paths by adding this to my .bashrc:
export PATH=$HOME/local/bin/:$PATH
export LD_LIBRARY_PATH=$HOME/local/lib
export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
export CPATH=$HOME/local/include
That should allow a newly compiled ruby to find and use the newly installed edge-openssl:
chris@chris-VirtualBox:~/repos/openssl$ rvm install 1.9.2 -C --with-openssl-dir=$HOME/local
Installing Ruby from source to: /home/chris/.rvm/rubies/ruby-1.9.2-p180, this may take a while depending on your cpu(s)...

ruby-1.9.2-p180 - #fetching
ruby-1.9.2-p180 - #extracted to /home/chris/.rvm/src/ruby-1.9.2-p180 (already extracted)
ruby-1.9.2-p180 - #configuring
ruby-1.9.2-p180 - #compiling
ruby-1.9.2-p180 - #installing
Removing old Rubygems files...
Installing rubygems dedicated to ruby-1.9.2-p180...
Installing rubygems for /home/chris/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Installation of rubygems completed successfully.
ruby-1.9.2-p180 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.2-p180 - #importing default gemsets (/home/chris/.rvm/gemsets/)
Install of ruby-1.9.2-p180 - #complete
chris@chris-VirtualBox:~/repos$ rvm --default use 1.9.2
Using /home/chris/.rvm/gems/ruby-1.9.2-p180
I create an rvm gemset (rvm use default@spdy) for my spdy work. This is more a force of habit than a real need since I will be using this VM exclusively for SPDY work. In that gemset, I install bundler:
chris@chris-VirtualBox:~/repos/spdy$ gem install bundler
Fetching: bundler-1.0.12.gem (100%)
Successfully installed bundler-1.0.12
1 gem installed
And, per Carson's instructions, I also install rake-compiler:
chris@chris-VirtualBox:~/repos/spdy$ gem install rake-compiler
Fetching: rake-compiler-0.7.8.gem (100%)
Successfully installed rake-compiler-0.7.8
1 gem installed
And the rest of the ruby gems required by the SPDY gem (with and assist from bundler):
chris@chris-VirtualBox:~/repos/spdy$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Installing bindata (1.3.1)
Installing diff-lcs (1.1.2)
Installing ffi (1.0.7) with native extensions
Installing ffi-zlib (0.2.0)
Installing rspec-core (2.5.1)
Installing rspec-expectations (2.5.0)
Installing rspec-mocks (2.5.0)
Installing rspec (2.5.0)
Using spdy (0.0.2) from source at /home/chris/repos/spdy
Using bundler (1.0.12)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Now, I install Carson's NPN-enabled eventmachine by cloning it from github:
chris@chris-VirtualBox:~/repos$ git clone git://github.com/carsonmcdonald/eventmachine.git
Initialized empty Git repository in /home/chris/repos/eventmachine/.git/
remote: Counting objects: 3792, done.
remote: Compressing objects: 100% (1263/1263), done.
Receiving objects: 100% (3792/3792), 794.81 KiB | 159 KiB/s, done.
remote: Total 3792 (delta 2702), reused 3339 (delta 2398)
Resolving deltas: 100% (2702/2702), done.
chris@chris-VirtualBox:~/repos$ cd eventmachine
chris@chris-VirtualBox:~/repos/eventmachine$ git checkout tls-npn
Branch tls-npn set up to track remote branch tls-npn from origin.
Switched to a new branch 'tls-npn'
chris@chris-VirtualBox:~/repos/eventmachine$ rake gem
(in /home/chris/repos/eventmachine)
rake-compiler must be configured first to enable cross-compilation
rake-compiler must be configured first to enable cross-compilation
rake-compiler must be configured first to enable cross-compilation
rake-compiler must be configured first to enable cross-compilation
mkdir -p pkg
Successfully built RubyGem
Name: eventmachine
Version: 1.0.0.beta.3
File: eventmachine-1.0.0.beta.3.gem
mv eventmachine-1.0.0.beta.3.gem pkg/eventmachine-1.0.0.beta.3.gem
chris@chris-VirtualBox:~/repos/eventmachine$ gem install pkg/eventmachine-1.0.0.beta.3.gem
Building native extensions. This could take a while...
Successfully installed eventmachine-1.0.0.beta.3
1 gem installed
Yay! That is progress. I could not compile yesterday so I am now officially one step further. So, does it work now?
chris@chris-VirtualBox:~/repos/spdy/examples$ ruby ./npn_spdy_server.rb
/home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:404:in `set_negotiable_protocols': undefined method `set_neg
otiable_protocols' for EventMachine:Module (NoMethodError)
from ./npn_spdy_server.rb:35:in `post_init'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:45:in `block in new'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:36:in `instance_eval'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/em/connection.rb:36:in `new'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1415:in `event_callback'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run_machine'
from /home/chris/.rvm/gems/ruby-1.9.2-p180@spdy/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:206:in `run'
from ./npn_spdy_server.rb:66:in `<main>'
Noooo!!!!!

Luckily I determine that this is caused by a bad gem install. Specifically, I had run the eventmachine install in a separate gnu-screen window (without the local openssl in its path). I add the necessary paths, re-run the gem install, and am good to go.

Unfortunately, when I access the service from Chrome, I now see this in the eventmachine output:
chris@chris-VirtualBox:~/repos/spdy/examples$ ruby ./npn_spdy_server.rb
[:SPDY, :connection_closed]
[:SPDY, :connection_closed]
[:SPDY, :connection_closed]
And, in the browser:


Dang. This is very similar to the behavior that I was seeing when I ran Chrome without --with-spdy=ssl the other day.

Soo.... I shut down Chrome and restart with with --with-spdy=ssl. My pinned tabs and extensions break (because that option seems to affect all sites) and it still does not work.

And then I restart and try once more without any command line options to find:



Hrm... better. I wish it would have worked right away, but I will take that as a small victory. It worked (it is SPDY) and I can still access GMail and other web pages. That is definitely progress.

That will suffice as a stopping point for the day. I will pick back up tomorrow to determine how stable this is and to see if I can use ssldump to sniff packets.


Day #8