我最初使用 rsolr 生成并连接到本地计算机上的 solr 核心。在我们迁移到 jruby 之前,这一切都在 ruby 中运行良好。我现在收到 localhost http 请求的 504 网关错误。这来自Open-uri
. 我们确实有一个代理,我已经取消设置它,设置它并用于Net::HTTP::Proxy
尝试连接到本地主机。
我得到的错误是:
require 'open-uri'
open("http://127.0.0.1:8984/solr/")
OpenURI::HTTPError: 504 Gateway Time-out
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:346:in `open_http'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:775:in `buffer_open'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:203:in `open_loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:201:in `open_loop'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:146:in `open_uri'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:677:in `open'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:33:in `open'
from (irb):3:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1489:in `loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'
我还尝试了 localhost -> 127.0.0.1、0.0.0.0 和我的实际本地 ip 192 的别名。
知道为什么会这样。jruby中的Open URI可以不处理重定向吗?
编辑:如果使用真实的本地 IP,即 192....(但不在 localhost,127.0.0.1 上),它会连接:
jruby-1.7.4 :013 > open("http://127.0.0.1:8985/solr/")
OpenURI::HTTPError: 504 Gateway Time-out
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:346:in `open_http'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:775:in `buffer_open'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:203:in `open_loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:201:in `open_loop'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:146:in `open_uri'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:677:in `open'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/open-uri.rb:33:in `open'
from (irb):13:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1489:in `loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/adamcryer/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'
jruby-1.7.4 :014 > open("http://192.168.2.210:8985/solr/")
=> #<StringIO:0x385715 @status=["200", "OK"], @meta={"content- type"=>"text/html;charset=UTF-8", "x-cache"=>"MISS from pH-squid", "x-cache-lookup"=>"MISS from pH-squid:3128", "via"=>"1.1 pH-squid:3128 (squid/2.7.STABLE9)", "connection"=>"close"}, @base_uri=#<URI::HTTP:0x2a717ef5 URL:http://192.x.x.x:8985/solr/>>
感谢您提前提供任何帮助
编辑:
这本质上是以下内容的副本: