On 04 December 2019 at 16:38, Andrew Stitcher wrote:
> On Tue, 2019-12-03 at 11:47 +0000, Bourne, Mark wrote:
> > With Python Proton version 0.29.0, the `get_connection_address`
> > method of `proton.reactor.Reactor` attempts to call
> > `connection.get_address()`.  However, that method doesn't seem to
> > exist, leading to an exception.  Code to reproduce this is attached
> > (demo.py - also copied at the end of this message in case this
> > mailing list strips attachments).  In this example, we already know
> > the broker address so it's not really necessary to use
> > `get_connection_address`, but our actual messaging handler holds
> > connections to multiple brokers and we use `get_connection_address`
> > to work out which one a message has come from.
> >
> >
> >
> > It's possible that we're not using `get_connection_address` as
> > intended, but this has worked in previous versions of Proton to get
> > the address of the broker from which a message was received.  This
> > was working with Proton 0.26.0, but breaks with 0.29.0.
> 
> This is very definitely a bug.
> 
> However the Reactor.get_connected_address() method is no longer the
> best way to  achieve what you're trying to do - use the
> Connection.connect_address property instead.
>       
> I'll fix the bug and note in the Reactor.get_connected_address() docs
> that it's deprecated for Connection.connected_address.
> Andrew

Thanks for the quick confirmation and suggestions.

As far as I can see from the API documentation, it looks like 
Connection.connect_address was only added in version 0.28.0 - is that correct?  
We may need to still support older versions for a while until everyone's 
repositories are updated (until last week ours was still on 0.26.0), but should 
be able to use Connection.connect_address fall back to 
Reactor.get_connection_address() if that's not available.

A slight difference from previous behaviour is that Connection.connect_address 
adds the 'amqp://' protocol to the URL if it wasn't specified when creating the 
connection, whereas Reactor.get_connection_address() previously didn't.  e.g. 
if the connection was created with '1.2.3.4:5672' as the URL, the older 
Reactor.get_connection_address() returned that exact same string, whereas 
Connection.connect_address now gives 'amqp://1.2.3.4:5672'.  It looks like we 
should be able to use something like str(proton.Url('1.2.3.4:5672')) to get a 
consistent form for comparisons, which would probably be more reliable anyway, 
so shouldn't be a big issue.  Just thought it might be worth mentioning, since 
it looks like the fixed Reactor.get_connection_address() just returns 
connection.connected_address so will now also add the protocol.

Thanks,
Mark.

-- 
Mark Bourne  MEng(Hons) MIET
Consultant Engineer
Roke Manor Research Limited

________________________________________
Roke Manor Research Limited, Romsey, Hampshire, SO51 0ZN, United Kingdom.Part 
of the Chemring Group. 
Registered in England & Wales. Registered No: 00267550
http://www.roke.co.uk
_______________________________________
The information contained in this e-mail and any attachments is proprietary to 
Roke Manor Research Limited and 
must not be passed to any third party without permission. This communication is 
for information only and shall 
not create or change any contractual relationship.
________________________________________

Reply via email to