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

connection_detail does not support hostname #411

Open
jllansford opened this issue Oct 6, 2023 · 5 comments
Open

connection_detail does not support hostname #411

jllansford opened this issue Oct 6, 2023 · 5 comments

Comments

@jllansford
Copy link

When using rhea to connect via ssl to our redhat amqp interconnect routers we need to specify the hostname parameter n the connection options or else we get an error about being rejected by local policy.

My understanding from the documentation is that hostname should default to host, however for us the connection fails unless specifically setting hostname to the same value that we use for host. (is this a bug?)

Bug or not setting hostname is trivial enough to do until we attempt to build in our failover. The hostname parameter from within the return value of the connection_details function does not appear to be supported.

@grs
Copy link
Member

grs commented Oct 10, 2023

It should be possible to include the hostname in the options field of the object returned by connection_details. Does that work for you?

@jllansford
Copy link
Author

Sorry for the late response I was occupied by some personal things.

Returning hostname in the connection_details function does not appear to work.

@grs
Copy link
Member

grs commented Nov 24, 2023

Sorry, bad advice first time round! You should be able to pass the hostname when using connection_details like this:

var container = require('rhea');

var options = {
    connection_details: function() {
        return {
            port: 5672,
            host: 'localhost',
        };
    },
    hostname: 'my-hostname'
};

container.connect(options);

@jllansford
Copy link
Author

Sorry, bad advice first time round! You should be able to pass the hostname when using connection_details like this:

var container = require('rhea');

var options = {
    connection_details: function() {
        return {
            port: 5672,
            host: 'localhost',
        };
    },
    hostname: 'my-hostname'
};

container.connect(options);

I'm not in the office right now so I can't test it. I believe my issue is that the hostname value needs to match the remote hostname of the broker.

So if we have a load-balanced set up with 4 brokers (broker1 - broker4) the connection_details function returns port: 5672, and one of the 4 host values (broker1 - broker4). However the hostname property does not seem supported as part of connection_detail function.

If we initialize hostname to "broker1", then when we fail over to broker2 - broker4 we get an error about a bad hostname. Any attempts to update the hostname property after initialization were not working for us.

@grs
Copy link
Member

grs commented Nov 24, 2023

I see what you mean now. Unfortunately the hostname in the open frame is not reset from options after the initial creation of the connection. This is actually independent of whether you are using connection_details. The only way at present to change it is to set it manually, e.g.

var container = require('rhea');
var connection;
var hostnames = ['foo', 'bar'];
var count = 0;

var options = {
    connection_details: function() {
        if (connection) {
            count = count + 1;
            var hostname = hostnames[count % hostnames.length];
            connection.local.open.hostname = hostname
        }
        return {
            port: 5672,
            host: 'localhost',
        };
    },
    hostname: hostnames[0],
};

connection = container.connect(options);

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

2 participants