It's a little embarrassing 'cause I've kind of been using these for a couple of years, but as they are ever so slightly obtuse :-> I've generally been lazy/pragmatic and did copy'n'paste of things that have worked.

Because of the various URL differences (the ones used by the python tools, the qpid::messaging amqp URL and the Java ConnectionURL I also wrote a ConnectionHelper class to allow me to specify URLs in any format). This class basically creates a Java ConnectionURL with sensible values filled in when I specify one of the shorter (AKA more convenient!!) formats.

I'm generally OK on the brokerList sub URLs and the options I put in there seem to be fine.....

However I've just been bitten. 'Cause I've been a bit lazy and mostly tested and tinkered with qpidd --auth no or actually used a proper user/password I ended up having defaults of guest:guest in ConnectionHelper. This hasn't hitherto been an issue for me but standing up a vanilla qpidd with auth yes the unsecured authentication username is anonymous *not* guest.....



The documentation http://qpid.apache.org/books/0.20/Programming-In-Apache-Qpid/html/QpidJNDI.html#id2553965 says:

amqp://[<user>:<pass>@][<clientid>]<virtualhost>[?<option>='<value>'[&<option>='<value>']]

But I'm not convinced that's accurate. I've been hacking around with a few ConnectionURLs in a JNDI file and

# simple URL with user = guest
#connectionfactory.ConnectionFactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'

# Omitting the clientid bit seems to work OK
#connectionfactory.ConnectionFactory = amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'

# Omitting the virtualhost bit seems to work too, but the slash is important e.g. /test and / work test does not?? #connectionfactory.ConnectionFactory = amqp://guest:guest@/?brokerlist='tcp://localhost:5672'


But I *cannot* get/figure out how to do anonymous from a Java Client to a C++ broker.

According to the BNF form in the documentation
connectionfactory.ConnectionFactory = amqp://clientid/test?brokerlist='tcp://localhost:5672'

*should* work as [<user>:<pass>@] ought to be optional, but that just gives "connectionFactory lookup failed, retrying" with both --auth no and --auth yes

Same for

connectionfactory.ConnectionFactory = amqp://@clientid/test?brokerlist='tcp://localhost:5672'

If I do

connectionfactory.ConnectionFactory = amqp://:@clientid/test?brokerlist='tcp://localhost:5672'

That actually connects to a broker with --auth no, but barfs with an error "warning Failed to retrieve sasl username" on a broker with --auth yes

connectionfactory.ConnectionFactory = amqp://anonymous:@clientid/test?brokerlist='tcp://localhost:5672' Actually connects to a broker with --auth no, but barfs with no error on a broker with --auth yes and a "connectionFactory lookup failed, retrying"

When I add info logging I get

main 2013-01-25 09:51:26,539 INFO [apache.qpid.client.AMQConnection] Connection:amqp://anonymous:********@clientid/test?brokerlist='tcp://localhost:5672' main 2013-01-25 09:51:26,973 INFO [qpid.client.protocol.AMQProtocolSession] Using ProtocolVersion for Session:0-10 main 2013-01-25 09:51:26,995 INFO [qpid.client.handler.ClientMethodDispatcherImpl] New Method Dispatcher:AMQProtocolSession[null] main 2013-01-25 09:51:27,016 INFO [apache.qpid.client.AMQConnection] Connecting with ProtocolHandler Version:0-10 main 2013-01-25 09:51:27,167 INFO [apache.qpid.client.AMQConnection] Unable to connect to broker at tcp://localhost:5672 org.apache.qpid.AMQException: *Cannot connect to broker: connection-forced: Authentication failed [error code 320: context in use*] at org.apache.qpid.client.AMQConnectionDelegate_0_10.makeBrokerConnection(AMQConnectionDelegate_0_10.java:203) at org.apache.qpid.client.AMQConnection.makeBrokerConnection(AMQConnection.java:609)
    at org.apache.qpid.client.A...............

Logging at DEBUG doesn't give any more useful info.

I've tried

connectionfactory.ConnectionFactory = amqp://anonymous:anonymous@clientid/test?brokerlist='tcp://localhost:5672' connectionfactory.ConnectionFactory = amqp://anonymous:""@clientid/test?brokerlist='tcp://localhost:5672' connectionfactory.ConnectionFactory = amqp://anonymous:''@clientid/test?brokerlist='tcp://localhost:5672' connectionfactory.ConnectionFactory = amqp://anonymous: @clientid/test?brokerlist='tcp://localhost:5672'


and they *all* barf out :-(

So could someone please tell me what the magic incantation is on a Java ConnectionURL for connecting with anonymous from a Java Client to a C++ broker.

just to confirm too that I've tried qpid-config with no parameters to the same broker with auth on and off and that works fine so it looks like anonymous "authentication" is actually working, just not with Java.

I'm still using 0.12 if that makes any difference (hope to hit 0.20 soon but wanted to look at this first)


Any ideas??

Cheers,
Frase






Reply via email to