You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Rich Stephens <rs...@sumglobaltech.com> on 2009/08/20 16:40:28 UTC

C++ client won't connect to Java broker

Using the latest release qpid java broker and C++ client code,
Compiled/running on Ubuntu.

The same java server has no problem acception messages via JMS from Java,
but whenever I try to connect to it from the C++ client using a URL, I get
the following exception thrown from connection->open(URL):

Cannot resolve amqp://guest:guest@/test?brokerlist='tcp://localhost:5672' :
Name or service not known (qpid/sys/posix/Socket.cpp: 157).

It appears that for some reason the OS cannot resolve the URL.  I have tried
many variations on the URL with the same results.

I can ping localhost, and I can telnet to localhost:5672 and see that the
server responds.

I have also tried using the connection->open(host,port) variation using
("localhost", 5672) as the args.  When I do that, the ->open() call simply
hangs my client program and never returns.

Is there something I am doing wrong configuration-wise?  In the URL?  Or is
there something I need to do in the OS so that the URL will be properly
recognized?

I had this EXACT same problem with the same code compiled IN MSVC on windows
(although the error message was slightly different, it was essentially the
same error, with the same behavior).

Any insights would be appreciated.  I have been struggling with this for a
week.

Thanks,
Rich Stpehens


-- 
View this message in context: http://n2.nabble.com/C-client-won-t-connect-to-Java-broker-tp3479487p3479487.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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


Re: C++ client won't connect to Java broker

Posted by Gordon Sim <gs...@redhat.com>.
Rich Stephens wrote:
> Thanks for the quick reply.
> 
> It seems I have made some rather silly errors in my client code:
> 
> 1) I was assigning the newSession to a local session variable instead of my
> class member (unintentionally)
> 2) I didn't realize that the "url" argument to open->(URL) was an actual
> qpid Url class rather than a URL string.  Should pay closer attention to the
> header files...
> 
> That said, I would have never had a clue as to the 0.10 URL format without
> your tip.  

Yes, we need to make that clear in the API reference docs at the very 
least.

> I have been looking around for some documentation on that format,
> but I haven't found any on the web as of yet -- some proposals, but nothing
> solid.  Could you possibly point me where I could find decisive
> documentation on the 0.10 url format beyond just "amqp:tcp:host:port"?

The 0-10 specification[1] defines the format ('connection.amqp-host-url' 
chapter 9, page 113) as:

         amqp_url          = "amqp:" prot_addr_list
         prot_addr_list    = [prot_addr ","]* prot_addr
         prot_addr         = tcp_prot_addr | tls_prot_addr

         tcp_prot_addr     = tcp_id tcp_addr
         tcp_id            = "tcp:" | ""
         tcp_addr          = [host [":" port] ]
         host              = <as per http://www.ietf.org/rfc/rfc3986.txt>
         port              = number]]>

[1] http://jira.amqp.org/confluence/display/AMQP/AMQP+Specification


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


Re: C++ client won't connect to Java broker

Posted by Jonathan Robie <jo...@redhat.com>.
Rich Stephens wrote:
> Thanks for the quick reply.
>
> It seems I have made some rather silly errors in my client code:
>
> 1) I was assigning the newSession to a local session variable instead of my
> class member (unintentionally)
> 2) I didn't realize that the "url" argument to open->(URL) was an actual
> qpid Url class rather than a URL string.  Should pay closer attention to the
> header files...
>
> That said, I would have never had a clue as to the 0.10 URL format without
> your tip.  I have been looking around for some documentation on that format,
> but I haven't found any on the web as of yet -- some proposals, but nothing
> solid.  Could you possibly point me where I could find decisive
> documentation on the 0.10 url format beyond just "amqp:tcp:host:port"?
>   

C++ uses the AMQP 0-10 format defined in Section 9.12 here (page 112):
**
http://jira.amqp.org/confluence/download/attachments/720900/amqp.0-10.pdf?version=1

Jonathan



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


Re: C++ client won't connect to Java broker

Posted by Rich Stephens <rs...@sumglobaltech.com>.
Thanks for the quick reply.

It seems I have made some rather silly errors in my client code:

1) I was assigning the newSession to a local session variable instead of my
class member (unintentionally)
2) I didn't realize that the "url" argument to open->(URL) was an actual
qpid Url class rather than a URL string.  Should pay closer attention to the
header files...

That said, I would have never had a clue as to the 0.10 URL format without
your tip.  I have been looking around for some documentation on that format,
but I haven't found any on the web as of yet -- some proposals, but nothing
solid.  Could you possibly point me where I could find decisive
documentation on the 0.10 url format beyond just "amqp:tcp:host:port"?

Thanks,
Rich S.
-- 
View this message in context: http://n2.nabble.com/C-client-won-t-connect-to-Java-broker-tp3479487p3481129.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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


Re: C++ client won't connect to Java broker

Posted by Gordon Sim <gs...@redhat.com>.
Rich Stephens wrote:
> Alright, so I'm now using the C++ qpid broker with the C++ client libs.  I'm
> using the code almost exactly as it is in the example on the main tab of the
> api doc.
> 
> However, I still get the same error when I try to use the
> connection.open(URL) form of the method:
> 
> Cannot resolve <whatever variation of the URL I try to use> : Name or
> service not known (qpid/sys/posix/Socket.cpp: 157). 

The url you had in your first mail was using the java brokers syntax. 
The qpid::Url class in the c++ client uses the url format defined for 
amqp 0-10 (e.g. amqp:tcp:localhost:5672)

> I can, however, connect using the connection.open(host,port) method.
> 
> That said, everything appears to go OK up until this point:
> 
> session.MessageTransfer(arg::content=message,
> arg::destination="amq.direct"):
> 
> The program blows up with a SIGABRT with the following error:
> 
> /usr/include/boost/shared_ptr.hpp:315: T* boost::shared_ptr<T>::operator->()
> const [with T = qpid::client::SessionImpl]: Assertion 'px != 0' failed.
> 
> Any ideas?

Looks like the session pointer is not valid. Did you assign to the 
session variable the result of connection.newSession()?

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


Re: C++ client won't connect to Java broker

Posted by Rich Stephens <rs...@sumglobaltech.com>.
Alright, so I'm now using the C++ qpid broker with the C++ client libs.  I'm
using the code almost exactly as it is in the example on the main tab of the
api doc.

However, I still get the same error when I try to use the
connection.open(URL) form of the method:

Cannot resolve <whatever variation of the URL I try to use> : Name or
service not known (qpid/sys/posix/Socket.cpp: 157). 

I can, however, connect using the connection.open(host,port) method.

That said, everything appears to go OK up until this point:

session.MessageTransfer(arg::content=message,
arg::destination="amq.direct"):

The program blows up with a SIGABRT with the following error:

/usr/include/boost/shared_ptr.hpp:315: T* boost::shared_ptr<T>::operator->()
const [with T = qpid::client::SessionImpl]: Assertion 'px != 0' failed.

Any ideas?

-- 
View this message in context: http://n2.nabble.com/C-client-won-t-connect-to-Java-broker-tp3479487p3480522.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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


Re: C++ client won't connect to Java broker

Posted by Aidan Skinner <ai...@gmail.com>.
On Thu, Aug 20, 2009 at 3:40 PM, Rich
Stephens<rs...@sumglobaltech.com> wrote:

> The same java server has no problem acception messages via JMS from Java,
> but whenever I try to connect to it from the C++ client using a URL, I get
> the following exception thrown from connection->open(URL):

This is, sadly, Just Not Going To Work. The M2.1 C++ client was the
last version that spoke AMQP 0-9, C++ clients from M3 onwards (M3, M4,
0.5) only speak 0-10. The Java client in M3 onwards speaks AMQP 0-8,
0-9 and 0-10, but the java broker currently only speaks 0-8 and 0-9.

There's a table at http://qpid.apache.org/download.html which explains
the situation a little more clearly.

- Aidan
-- 
Apache Qpid - AMQP, JMS, other messaging love http://qpid.apache.org
"A witty saying proves nothing" - Voltaire

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