Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method call gives an error "HTTPClient::ConnectTimeoutError" with different adapters #939

Open
yaairfernando opened this issue Sep 21, 2020 · 9 comments

Comments

@yaairfernando
Copy link

yaairfernando commented Sep 21, 2020

Bug report

Current behavior:
I get an error when calling a method, I am not sure why I am getting this error but I think is related to the adapter that as far as I know httpclient is the default adapter. I have tried to set a different adapter like excon but I get the same error. I hope you can help me out.

I have also tried to add some attributes like, open_timeout: 100, read_timeout: 100, raise_errors: false, follow_redirects: true, host: "http://localhost:3000", but I still get the error.

I also tried with different versions of savon 2.11.1, 2.3.3, 2.12.0

Steps to reproduce current behavior:

  WSDL_URL = 'https://www.superfinanciera.gov.co/SuperfinancieraWebServiceTRM/TCRMServicesWebService/TCRMServicesWebService?WSDL'
  @client = Savon.client(wsdl: WSDL_URL, adapter: :net_http)  # I have also tried with excon and httpclient
  response = @client.call(:query_tcrm)

This code gives me this error depending on the adapter.

.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/socksify-1.7.1/lib/socksify.rb:178:in `initialize': execution expired (HTTPClient::ConnectTimeoutError)

.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/excon-0.76.0/lib/excon/socket.rb:285:in `select_with_timeout': connect_write timeout reached (Excon::Error::Timeout)

Net::OpenTimeout (execution expired):

Expected behavior:
The method call should be successful.

System information:

  • ruby version: '2.6.4'
  • savon version: '2.12.0'
@olleolleolle
Copy link
Contributor

olleolleolle commented Sep 22, 2020

Here's a runnable example, with the failure described

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'savon'
end

WSDL_URL = 'https://www.superfinanciera.gov.co/SuperfinancieraWebServiceTRM/TCRMServicesWebService/TCRMServicesWebService?WSDL'
pp client = Savon.client(wsdl: WSDL_URL) 
pp client.operations
pp response = client.call(:query_tcrm)

pp response

Diagnostic question:
Can you use SmartBear's "SoapUI Open Source" to call this Web Service operation? https://www.soapui.org/downloads/soapui/

I tried with this, too, no change:

  gem 'wasabi', '= 3.5.0'  # Here, I experimented, used an earlier release of Wasabi, a dependency
                                               # didn't work with that, either

@yaairfernando
Copy link
Author

I tried running the Web Service with Python and it worked. So I know the web service is working. I also used SoapUI Open Source.

So there is a problem with the Web Service or with the configurations on my side when using the gem?

@marcosdemelo
Copy link

@YairFernando67 Have you seen this below? Could you check if it solves your problem and report here?

ruby/ruby#597 (comment)

@yaairfernando
Copy link
Author

@marcosdemelo I tried it but it didn't work.

I also try adding env_namespace: 'soap', but didn't work either.

@client = Savon.client(wsdl: WSDL_URL, env_namespace: 'soap')

@marcosdemelo
Copy link

marcosdemelo commented Oct 8, 2020

@YairFernando67 are you using the certificate that they recommend in the documentation?

Search it on Google: superfinanciera wsdl pdf

20151228manualserviciowebtrm.pdf

@yaairfernando
Copy link
Author

@marcosdemelo yes I am using the certificate but I get the following errors.

  file = File.open('lib/cert.cer', "r")
  @client = Savon.client(wsdl: WSDL_URL, ssl_cert_file: file.read, ssl_cert_key_file: file.read, namespace_identifier: 'xw', 
  env_namespace: 'soap')
  response = @client.call(:query_tcrm)
  p response
rescue HTTPI::SSLError => e
  p e.message

httpi-2.4.5/lib/httpi/auth/ssl.rb:128:in `read': File name too long @ rb_sysopen - -----BEG (Errno::ENAMETOOLONG)

And if I pass the certificate like this.

  @client = Savon.client(wsdl: WSDL_URL, ssl_cert_file: 'lib/cert.cer', ssl_cert_key_file: 'lib/cert.cer', namespace_identifier: 'xw', 
  env_namespace: 'soap')
  response = @client.call(:query_tcrm)
  p response
rescue HTTPI::SSLError => e
  p e.message

I get this other error.

httpi-2.4.5/lib/httpi/auth/ssl.rb:144:in `read': Could not parse PKey: no start line (OpenSSL::PKey::PKeyError)

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 25, 2020
@clushie
Copy link

clushie commented Mar 25, 2021

I'm also affected by this and can't figure out a way to get https working.

My gut-feeling is that the url is passed at a later stage than the httpi request initialization when using wsdl which will HTTPI (or any other library) attempt to connect to a non ssl-host even though https is defined? But I might be completely wrong with that assumption.

PS: I'm using basic auth, no client/auth certificates are needed.

This is where I'd expect to tell HTTPI to use ssl:

@http_request = http_request || HTTPI::Request.new

Update: Turns out the underlying problem was the SOAP document itself which contained a hard-coded port that resulted in these timeouts

Checking the https://www.superfinanciera.gov.co/SuperfinancieraWebServiceTRM/TCRMServicesWebService/TCRMServicesWebService?WSDL URL provided in the example above you'll notice the http://10.172.14.199:8183/SuperfinancieraWebServiceTRM/TCRMServicesWebService/TCRMServicesWebService. Running the minimal-example on ruby 2.5 you'll get a more helpful timeout message too:

Traceback (most recent call last):
16: from ruby.rb:11:in `<main>'
15: from /usr/local/bundle/gems/savon-2.12.1/lib/savon/client.rb:36:in `call'
14: from /usr/local/bundle/gems/savon-2.12.1/lib/savon/operation.rb:54:in `call'
13: from /usr/local/bundle/gems/savon-2.12.1/lib/savon/operation.rb:94:in `call_with_logging'
12: from /usr/local/bundle/gems/savon-2.12.1/lib/savon/request_logger.rb:12:in `log'
11: from /usr/local/bundle/gems/savon-2.12.1/lib/savon/operation.rb:94:in `block in call_with_logging'
10: from /usr/local/bundle/gems/httpi-2.4.5/lib/httpi.rb:133:in `post'
 9: from /usr/local/bundle/gems/httpi-2.4.5/lib/httpi.rb:161:in `request'
 8: from /usr/local/bundle/gems/httpi-2.4.5/lib/httpi/adapter/net_http.rb:38:in `request'
 7: from /usr/local/bundle/gems/httpi-2.4.5/lib/httpi/adapter/net_http.rb:89:in `do_request'
 6: from /usr/local/lib/ruby/2.5.0/net/http.rb:909:in `start'
 5: from /usr/local/lib/ruby/2.5.0/net/http.rb:920:in `do_start'
 4: from /usr/local/lib/ruby/2.5.0/net/http.rb:935:in `connect'
 3: from /usr/local/lib/ruby/2.5.0/timeout.rb:103:in `timeout'
 2: from /usr/local/lib/ruby/2.5.0/timeout.rb:93:in `block in timeout'
 1: from /usr/local/lib/ruby/2.5.0/net/http.rb:936:in `block in connect'
/usr/local/lib/ruby/2.5.0/net/http.rb:939:in `rescue in block in connect': Failed to open TCP connection to 10.172.14.199:8183 (Network is unreachable - connect(2) for "10.172.14.199" port 8183) (Errno::ENETUNREACH

For us the fix was telling our third-party API to change in their Microsoft SOAP settings to the correct soap:address location, but seeing several people are affected by this maybe support for overwriting the soap address host/port/url would be helpful (in case that is not possible yet).

@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants