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.gemWow. More than a bit anti-climatic. Surely it can't just work.
Building native extensions. This could take a while...
Successfully installed eventmachine-1.0.0.beta.3
1 gem installed
It doesn't.
It starts OK, but accessing the server results in:
➜ examples git:(master) ✗ ruby npn_spdy_server.rbHrm... aw nuts. I forgot to rebuild ruby with the new openssl install:
/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>'
rvm remove 1.9.2I reinstall the packages needed for the SPDY gem and eventmachine:
rvm install 1.9.2 -C --with-openssl-dir=$HOME/local
gem install rake-compiler rspec bundler bindata ffi-zlibFinally, 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.rbHoly cow.
/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
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.soBah!
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)
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/:$PATHWith that, I finally have an eventmachine linked against my local, npn-enabled openssl libraries:
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
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.soFinally, I retry the npn_spdy_server:
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)
1.9.2@spdy ~/repos/spdy/examples (master)$ ruby npn_spdy_server.rbYay! Never have I been so glad to see an error message. Because, it the browser, I see:
[: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>'
The error message is solved in node.js, but still need to fix it here in ruby. Another day.
Day #21
No comments:
Post a Comment