3

我在 1.9 模式下运行带有 jruby 1.7.0 的 rails 3 应用程序,当我的一个文件上传 gem 尝试建立 https 连接时,它失败并出现以下异常:

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'

我在这里在 stackoverflow 上发现了一个类似的问题:JRuby Heroku Gem,但建议的答案是在 1.8 模式下运行 jruby,因为我们的整个应用程序使用 1.9 功能和语法,所以我不能这样做。是否有人对如何修复或解决此异常有任何想法或建议?

谢谢。

4

2 回答 2

4

好的,这是我的 hacky 解决方案:

由于这是一个 Rails 项目,我创建了一个名为的文件excon_hack.rb并将其放在initializers文件夹中。

module Excon
  DEFAULT_NONBLOCK = false
end

这使得连接块,这对我来说并不重要,更重要的是,它修复了我的错误。

于 2012-11-20T17:28:42.207 回答
0

另一种选择是将 jruby-openssl 降级到 0.7.4。我还不清楚这是否有效地将 excon 恢复为阻塞模式,或者只是让非阻塞工作。

于 2012-11-21T18:57:03.093 回答