Faraday: Faraday::Error::ConnectionFailed

Created on 27 Feb 2019  ·  4Comments  ·  Source: lostisland/faraday

I am reporting this because the final error refers to Faraday. I have already reported this issue to Kickscraper, but they don't believe the issue resides within the Kickscraper scripts - https://github.com/markolson/kickscraper/issues/47.

Apologies if this issue doesn't reside with Faraday, but I would appreciate any assistance or insights this community can provide.

Basic Info

  • Faraday Version: 0.8.11
  • Faraday-middleware Version: 0.13.1
  • Ruby Version: 2.6.1

Issue description

C:\Program Files\Ruby\Ruby26\lib\ruby\gems\2.6.0\gems\kickscraper-0.2.4>rake console
fatal: not a git repository (or any of the parent directories): .git
irb(main):001:0> c = Kickscraper.client
Traceback (most recent call last):
       16: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday-0.8.11/lib/faraday/request/url_encoded.rb:14:in `call'
       15: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday-0.8.11/lib/faraday/response.rb:8:in `call'
       14: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday_middleware-0.13.1/lib/faraday_middleware/response/follow_redirects.rb:75:in `call'
       13: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday_middleware-0.13.1/lib/faraday_middleware/response/follow_redirects.rb:87:in `perform_with_redirection'
       12: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday_middleware-0.13.1/lib/faraday_middleware/response_middleware.rb:31:in `call'
       11: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/kickscraper-0.2.4/lib/kickscraper/connection.rb:25:in `call'
       10: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday-0.8.11/lib/faraday/adapter/net_http.rb:39:in `call'
        9: from C:/Program Files/Ruby/Ruby26/lib/ruby/gems/2.6.0/gems/faraday-0.8.11/lib/faraday/adapter/net_http.rb:76:in `perform_request'
        8: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:1470:in `request'
        7: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:919:in `start'
        6: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:930:in `do_start'
        5: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:945:in `connect'
        4: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/timeout.rb:103:in `timeout'
        3: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
        2: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:946:in `block in connect'
        1: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'
Faraday::Error::ConnectionFailed (Failed to open TCP connection to localhost:8888 (No connection could be made because the target machine actively refused it. - connect(2) for "localhost" port 8888))

Steps to reproduce

Ruby installation:

rubyinstaller-2.6.1-1-x86.exe installed to 'C:\Program Files\Ruby\Ruby26'

Gems installation:
Extracted rubygems-3.0.2.zip to C:\Program Files\Ruby\gems\.
Installed with cd C:\Program Files\Ruby\rubygems\3.0.2 && ..\..\Ruby26\bin\ruby.exe setup.rb

Kickscraper installation:

'C:\Program Files\Ruby\Ruby26\bin\gem' install kickscraper
Fetching faraday_middleware-0.13.1.gem
Fetching faraday-0.8.11.gem
Fetching multipart-post-1.2.0.gem
Fetching kickscraper-0.2.4.gem
Fetching multi_json-1.13.1.gem
Fetching uri-query_params-0.7.1.gem
Fetching hashie-2.1.2.gem
Successfully installed multipart-post-1.2.0
Successfully installed faraday-0.8.11
Successfully installed faraday_middleware-0.13.1
Successfully installed multi_json-1.13.1
Successfully installed hashie-2.1.2
Successfully installed uri-query_params-0.7.1
Successfully installed kickscraper-0.2.4
Parsing documentation for multipart-post-1.2.0
Installing ri documentation for multipart-post-1.2.0
Parsing documentation for faraday-0.8.11
Installing ri documentation for faraday-0.8.11
Parsing documentation for faraday_middleware-0.13.1
Installing ri documentation for faraday_middleware-0.13.1
Parsing documentation for multi_json-1.13.1
Installing ri documentation for multi_json-1.13.1
Parsing documentation for hashie-2.1.2
Installing ri documentation for hashie-2.1.2
Parsing documentation for uri-query_params-0.7.1
Installing ri documentation for uri-query_params-0.7.1
Parsing documentation for kickscraper-0.2.4
Installing ri documentation for kickscraper-0.2.4
Done installing documentation for multipart-post, faraday, faraday_middleware, m
ulti_json, hashie, uri-query_params, kickscraper after 74 seconds
7 gems installed

Launch Kickscraper:

C:\Program Files\Ruby\Ruby26\lib\ruby\gems\2.6.0\gems\kickscraper-0.2.4>rake console
irb(main):001:0> c = Kickscraper.client

Most helpful comment

Thank you for solving an issue that was completely outside of your codebase. You guys are awesome, and quick!

On Feb 27, 2019, at 7:18 AM, Olle Jonsson notifications@github.com wrote:

Closed #886.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

All 4 comments

Hi @mattmill30, the error you're getting back is quite clear:

Faraday::Error::ConnectionFailed (Failed to open TCP connection to localhost:8888 (No connection could be made because the target machine actively refused it. - connect(2) for "localhost" port 8888))

Apparently the Kickscraper.client expects a server to be listening on your machine on port 8888, but it seems like that's not the case.
If that's the only issue, I'm afraid this is not a bug with Faraday as the issue seems to be that there's no server listening on localhost:8888.

As you can see from the stacktrace, the last call is

1: from C:/Program Files/Ruby/Ruby26/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'

so from Faraday's point of view, the request is correctly passed through to the adapter (Net::HTTP in this case), but then something is wrong while performing it.
The reason you see a Faraday error raised is because we rescue and wrap adapters exceptions so that if you decide to change the adapter in the future you don't need to change your code. It doesn't mean there was an issue with Faraday.

I agree with @benrugg that this looks like a proxy issue.
I'd suggest you to call Kickscraper.proxy and see what that returns.
I'm sorry to send you back to Kickscraper but I'm quite comfortable this is not an issue with Faraday for the reasons highlighted above

Thanks @iMacTia, I've run 'c = Kickscraper.proxy' and it returns "https://localhost:8888".

How would I disable the proxy?

@mattmill30 I'm going to close this Issue (not a part of the Faraday project).

Here are some notes in passing about the proxy setting in the project:

The Kickscraper.configure block has client-configuring lines in it. One of the configurations is proxy. Source

Kickscraper.configure do |config|
  config.email = '[email protected]'
  config.password = 'This is not my real password. Seriously.'
  config.proxy = nil
end

Set it either to config.proxy = nil or to config.proxy = "".

Otherwise, seek out the LOCAL_PROXY constant, in your scripts, and do not set it.

Example of it being set:
https://github.com/markolson/kickscraper/blob/cef996ae73ef3166703d0cb9e452482cb5695c1a/spec/test_constants.rb

Hope this helps!

Thank you for solving an issue that was completely outside of your codebase. You guys are awesome, and quick!

On Feb 27, 2019, at 7:18 AM, Olle Jonsson notifications@github.com wrote:

Closed #886.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asf-stripe picture asf-stripe  ·  3Comments

Lewiscowles1986 picture Lewiscowles1986  ·  4Comments

iMacTia picture iMacTia  ·  3Comments

yusefu picture yusefu  ·  3Comments

jeffb-stell picture jeffb-stell  ·  5Comments