Search code examples
rubyruby-on-rails-3jrubyjruby-openssl

OpenSSL::SSL::SSLError in jruby 1.6.7/1.7.0 1.9 mode


I'm running a rails 3 app with jruby 1.7.0 in 1.9 mode, and when one of my file uploading gems tries to make a https connection, it fails with the following exception:

Excon::Errors::SocketError: write would raise (OpenSSL::SSL::SSLError)
    from org/jruby/ext/openssl/SSLSocket.java:626:in `syswrite_nonblock'
    from /home/x/.rvm/gems/jruby-1.7.0@global/gems/jruby-openssl-0.7.7/lib/1.9/openssl/buffering.rb:375:in `write_nonblock'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/excon-0.16.7/lib/excon/socket.rb:139:in `write'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/excon-0.16.7/lib/excon/ssl_socket.rb:84:in `write'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/excon-0.16.7/lib/excon/connection.rb:243:in `request_kernel'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/excon-0.16.7/lib/excon/connection.rb:103:in `request'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/core/connection.rb:20:in `request'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/rackspace.rb:71:in `authenticate'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/rackspace/storage.rb:146:in `authenticate'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/rackspace/storage.rb:95:in `initialize'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/core/service.rb:68:in `new'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/fog-1.7.0/lib/fog/storage.rb:34:in `new'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/carrierwave-0.6.2/lib/carrierwave/storage/fog.rb:106:in `connection'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/carrierwave-0.6.2/lib/carrierwave/storage/fog.rb:323:in `connection'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/carrierwave-0.6.2/lib/carrierwave/storage/fog.rb:335:in `directory'
    from /home/x/.rvm/gems/jruby-1.7.0/gems/carrierwave-0.6.2/lib/carrierwave/storage/fog.rb:250:in `store'

I found a similar issue on stackoverflow here: JRuby Heroku Gem, but the suggested answer is run jruby in 1.8 mode which I cannot do since our entire app uses 1.9 features and syntax. Does anybody have any ideas or suggesetions on how to fix or get around this exception?

Thanks.


Solution

  • Ok, so here's my hacky solution:

    As this is a Rails project, I created a file called excon_hack.rb and put it in the initializers folder.

    module Excon
      DEFAULT_NONBLOCK = false
    end
    

    This makes the connection block, which doesn't matter to me, and more importantly, it fixes my error.