You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2012/01/30 16:23:23 UTC

[c++ broker] Anyone have a good algorithm for determining if 2 addresses (protocol:host:port) are for the same broker?

Puzzle for you:

I want a broker to be able to eliminate its own addresss from a multi-address 
URL so that it doesn't end up connecting to itself. Anyone got a technique for 
that? It has to work with IPv4, IPv6, DNS names, /etc/host names and any other 
way a user is allowed to express a broker address. It has to work for all the 
protocols the broker supports and it has to work on hosts with multiple NICs.

Best I can come up with so far is for the broker to connect to all the addresses 
and send a UUID or some such token, then see if it gets a connection back to 
itself - if so eliminate the address. Anyone got a simpler solution?

Cheers,
Alan.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


RE: [c++ broker] Anyone have a good algorithm for determining if 2 addresses (protocol:host:port) are for the same broker?

Posted by Steve Huston <sh...@riverace.com>.
How about...

- Look up all the addresses in the URL - resolve to IPv4/6 addresses
- Compare each one to the IPv4/6 addresses on each network interface on
the system

-Steve

> -----Original Message-----
> From: Alan Conway [mailto:aconway@redhat.com]
> Sent: Monday, January 30, 2012 10:23 AM
> To: Qpid Dev
> Subject: [c++ broker] Anyone have a good algorithm for determining if 2
> addresses (protocol:host:port) are for the same broker?
> 
> Puzzle for you:
> 
> I want a broker to be able to eliminate its own addresss from a
multi-address
> URL so that it doesn't end up connecting to itself. Anyone got a
technique for
> that? It has to work with IPv4, IPv6, DNS names, /etc/host names and any
> other way a user is allowed to express a broker address. It has to work
for all
> the protocols the broker supports and it has to work on hosts with
multiple
> NICs.
> 
> Best I can come up with so far is for the broker to connect to all the
> addresses and send a UUID or some such token, then see if it gets a
> connection back to itself - if so eliminate the address. Anyone got a
simpler
> solution?
> 
> Cheers,
> Alan.
> 
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: [c++ broker] Anyone have a good algorithm for determining if 2 addresses (protocol:host:port) are for the same broker?

Posted by Andrew Stitcher <as...@redhat.com>.
On Mon, 2012-01-30 at 10:23 -0500, Alan Conway wrote:
> Puzzle for you:
> 
> I want a broker to be able to eliminate its own addresss from a multi-address 
> URL so that it doesn't end up connecting to itself. Anyone got a technique for 
> that? It has to work with IPv4, IPv6, DNS names, /etc/host names and any other 
> way a user is allowed to express a broker address. It has to work for all the 
> protocols the broker supports and it has to work on hosts with multiple NICs.
> 
> Best I can come up with so far is for the broker to connect to all the addresses 
> and send a UUID or some such token, then see if it gets a connection back to 
> itself - if so eliminate the address. Anyone got a simpler solution?

Given the need for broad applicability I think your solution is probably
the only thing that is likely to work - I think there is no way to
figure out if an broker address is you without actually asking the
remote who it is. With one addition to what you've specified - if no
broker is contactable on the address/port then you should make no
assumption about whether or not it is the same broker, as even routes to
yourself can come and go; by the same token you need to make the
determination every time you have to reconnect using the same
address/port.

> 
> Cheers,
> Alan.
> 
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
> 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org