Coder Social home page Coder Social logo

Comments (8)

johnhamelink avatar johnhamelink commented on August 23, 2024

Hey @kuzmik,

First of all, thanks for using diplomat! Thats an interesting use case, not something I've come across before. I'll take a look a little later to see if I can come up with a solution for you.

JH

from diplomat.

johnhamelink avatar johnhamelink commented on August 23, 2024

Hey @kuzmik

Using Faraday on its own you can set a proxy as such:

Faraday.new(:proxy => 'http://proxy.example.com:80')
Faraday.new(:proxy => {
  :uri      => 'http://proxy.example.com',
  :user     => 'foo',
  :password => 'bar'
})

Now I haven't tested this, but I'd be willing to bet that setting :proxy to nil would stop it using any proxy environment variable. Could you run a test where you try to run Faraday on its own and setting proxy to nil? If that works, I think we can make a fix for you to set your own parameters.

from diplomat.

kuzmik avatar kuzmik commented on August 23, 2024

Sure, I will give it a whirl sometime today and let you know what happens!

from diplomat.

kuzmik avatar kuzmik commented on August 23, 2024

Setting to nil doesn't do the trick... but setting it to '' does. Weird.

[16] pry(main)> conn = Faraday.new(:url => 'https://localhost:30570', :proxy => nil).proxy => #<struct Faraday::ProxyOptions uri=#<URI::HTTP:0x00000002530b40 URL:http://webproxy:3128>, user=nil, password=nil>

[17] pry(main)> conn = Faraday.new(:url => 'http://localhost:30570', :proxy => '').proxy => #<struct Faraday::ProxyOptions uri=#<URI::Generic:0x0000000291cbc8 URL:>, user=nil, password=nil> [18] pry(main)>

from diplomat.

johnhamelink avatar johnhamelink commented on August 23, 2024

Hey @kuzmik sorry I didn't get back to this message - how rude of me!

It seems based on what you sent me that the issue is with Faraday, not with diplomat - if you find that's not the case please reopen this thread and I'll work with you to get the problem resolved.

Thanks!
JH

from diplomat.

literatesnow avatar literatesnow commented on August 23, 2024

We have the same situation where Faraday is using ENV http_proxy (and ignoring ENV no_proxy) to connect to consul running on localhost via the proxy which results in HTTP 502's. Could we get Diplomat to force Faraday into not using the proxy?

from diplomat.

johnhamelink avatar johnhamelink commented on August 23, 2024

Hey @literatesnow! Looking through Faraday's Issues list, it seems like this PR will do exactly what you need: lostisland/faraday#471. Because the issue is coming from Faraday, it needs to be fixed in Faraday in order for this to work.

In the meantime, you can use @kuzmik's findings (setting :proxy => '' in Faraday's connection) to query with the proxy explicitly turned off for consul. You might do it like this:

@faraday = Faraday.new(:url => 'http://localhost:8500', :proxy => '')
@diplomat_kv = Diplomat::Kv.new(@faraday)
@diplomat_kv.get('lorem')

You could probably turn that idea into a wrapper class which you could use in the meantime to keep your code clean until this issue is fully resolved.


I think the long-term goal to fix this should be to swap out Faraday with Hurley as it seems to be under active maintenance as opposed to Faraday which seems to be effectively deprecated. However that would be a breaking change for people who use Faraday's middlewares, and for that reason, we have to either wait until someone comes along with an adapter for Faraday middleware (not an unlikely thing to happen) or release a major and breaking revision.

from diplomat.

literatesnow avatar literatesnow commented on August 23, 2024

@johnhamelink Thanks very much for the workaround, I'll use it in the meantime (was missing the Diplomat::Kv.new part).

from diplomat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.