sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
656 stars 411 forks source link

Getting exception Host not found (JIRA::HTTPError) behind proxy server and HTTPS #284

Open OliPelz opened 6 years ago

OliPelz commented 6 years ago

Hi, i am using the latest release 1.5.0. When running the following code:

#!/opt/gitlab/embedded/bin/ruby
#require 'jira-ruby'
require './lib/jira-ruby-1.5.0/lib/jira-ruby.rb'

uri = URI.parse('https://jira.xxxx.com/') # Your Jira URL
site = uri.scheme+'://'+uri.host # Protocol + Domain
options = {
  :username     => xxx',
  :password     => 'xxx',
  :site         => site,
  #:use_ssl      => false,
  :rest_base_path => uri.path,
  :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
  :context_path => '',
  :auth_type    => :basic,
  :proxy_address => "xxxx",
  :proxy_port => "8080"

}
client = JIRA::Client.new(options)
puts client.ServerInfo.all.attrs

I am getting the following exception output:

/home/xxx/ruby-code/lib/jira-ruby-1.5.0/lib/jira/request_client.rb:16:in `request': Host not found (JIRA::HTTPError)
        from /home/xxx/ruby-code/lib/jira-ruby-1.5.0/lib/jira/client.rb:228:in `request'
        from /home/xxx/ruby-code/lib/jira-ruby-1.5.0/lib/jira/client.rb:206:in `get'
        from /home/xxx/ruby-code/lib/jira-ruby-1.5.0/lib/jira/resource/serverinfo.rb:13:in `all'
        from /home/xxx/ruby-code/lib/jira-ruby-1.5.0/lib/jira/base_factory.rb:33:in `block (2 levels) in delegate_to_target_class'
        from ./jira_client.rb:27:in `<main>'

Please note that I am using the embedded Gitlab ruby interpreter because the problem I am trying to solve originally is the same in Gitlab when trying to connect to Jira (same error message).

The hostname I am using is fully dig- and pingable from the server.

I can also do the exact same REST HTTPS request with all the parameters from above on the server using curl or another simple ruby script using basic Net::HTTP::Proxy and Net::HTTP.start functions successfully.

Thank you for your help Oliver

garlou commented 6 years ago

I'm also recently experiencing this problem