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

Hutch.connect erases Hutch::Config #256

Open
niuage opened this issue Oct 10, 2016 · 6 comments
Open

Hutch.connect erases Hutch::Config #256

niuage opened this issue Oct 10, 2016 · 6 comments

Comments

@niuage
Copy link

niuage commented Oct 10, 2016

Hey,

We updated Hutch from 0.21 to 0.22.1, and we now have the following issue:

> Hutch::Config.get(:mq_host)
# => xyz.rmq.cloudamqp.com

> Hutch.connected?
# => nil

> Hutch.connect
#2016-10-10T22:14:44Z 3 INFO -- connecting to rabbitmq (amqp://guest@127.0.0.1:5672/)
# [...] Could not establish TCP connection to 127.0.0.1:5672 [...]

> Hutch::Config.get(:mq_host)
# => "127.0.0.1"

Notice how the Hutch::Config value is correct the first time, then after calling .connect, it's different, and is back to the default value?

Looking at the code...

def self.connect(options = {}, config = Hutch::Config)
    return if connected?

    @broker = Hutch::Broker.new(config)
    @broker.connect(options)
end

... it should be using the Hutch::Config class as default, and I checked the value of the mq_host attribute just before.

Interestingly, after all this mess, if I reset the values in the config class, with Hutch::Config.set..., and then call Hutch.connect, it works. Could this be a thread/fork issue? We're on heroku, just fyi.

Any idea about what's going on? Thanks.

@zuuno
Copy link

zuuno commented Oct 12, 2016

Investigating, it appears to be related to this commit:

6bd0cc8

logger called from the broker resets the connection settings

@niuage
Copy link
Author

niuage commented Oct 12, 2016

Good find, thanks for looking into it.

@olleolleolle
Copy link
Contributor

olleolleolle commented Oct 19, 2016

@niuage Are you able to try to try to reproduce with current master? Here's a commits list between that tag (which is latest release) and HEAD: 23ad748...master

The last line of config.rb is "please initialize with the defaults unless something is set".
https://github.com/gocardless/hutch/blob/master/lib/hutch/config.rb#L270 In the released version, that line isn't there.

Is that line Hutch::Config.initialize in lib/hutch/logging.rb now superfluous?

@olleolleolle
Copy link
Contributor

@niuage Please re-test with 0.23.1.

@olleolleolle
Copy link
Contributor

@niuage Have you had the time to look into this?

@niuage
Copy link
Author

niuage commented Jan 23, 2017

I haven't yet, sorry. I'll try today possibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants