You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Alexander Nagel <al...@acwn.de> on 2021/02/18 15:20:46 UTC

Help needed with first steps with libqpid-proton-cpp

Hi folks,

I'm trying to build a client for a rabbitmq broker.
The client should send messages.

I'm following the examples like
https://github.com/apache/qpid-proton/blob/master/cpp/examples/simple_send.cpp

My software stack is:
Debian stable with package libqpid-proton-cpp12 Version 0.22.0
g++ --version: g++ (Debian 8.3.0-6) 8.3.0


My problem:
With the code below I can connect successfully to rabbitmq, but the
user is always the default one (guest). When I change the queue name
from "checkermq" to something else the queue is created also
successfully.

The code doesn't seem to accept the user and password, which I have
defined in user and credentials. The user / password exists on the
broker of course. 

* What do I miss here?


Regards,
Alexander



My code so far (the relevant parts only)
There isn't much more actually. I'm still in the "exploring phase")
But from my understanding this should be enough for the login with a
different user.

header file

class listener : public proton::messaging_handler
{
...
};

code file:

listener::listener (std::string servername, std::string port,
std::string user, std::string credentials) : m_servername (servername),
m_port (port), m_user (user), m_credentials (credentials) { }

void listener::on_container_start (proton::container &c)
{
  proton::connection_options co;
  m_url = m_servername + ":" + m_port + "/checkermq";
  co.user (m_user);
  co.password (m_credentials);
  co.sasl_enabled (true);
  m_sender = c.open_sender(m_url, co);
}

In the main.cpp I start it with

 listener l (servername, port, user, credentials);
 proton::container(l).run ();

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Help needed with first steps with libqpid-proton-cpp

Posted by Alexander Nagel <al...@acwn.de>.

On Fri, 19 Feb 2021 10:04:26 +0000
Robbie Gemmell <ro...@gmail.com> wrote:

> On Thu, 18 Feb 2021 at 15:20, Alexander Nagel <al...@acwn.de>
> wrote:
> >
> > Hi folks,
> >
> > I'm trying to build a client for a rabbitmq broker.
> > The client should send messages.
> >
> > I'm following the examples like
> > https://github.com/apache/qpid-proton/blob/master/cpp/examples/simple_send.cpp
> >
> > My software stack is:
> > Debian stable with package libqpid-proton-cpp12 Version 0.22.0
> > g++ --version: g++ (Debian 8.3.0-6) 8.3.0
> >  
> 
> Note that Proton 0.22.0 is nearing a few years old. The current
> release is 0.33.0.
> 
> >
> > My problem:
> > With the code below I can connect successfully to rabbitmq, but the
> > user is always the default one (guest). When I change the queue name
> > from "checkermq" to something else the queue is created also
> > successfully.
> >
> > The code doesn't seem to accept the user and password, which I have
> > defined in user and credentials. The user / password exists on the
> > broker of course.
> >
> > * What do I miss here?
> >  
> 
> My first guess would be that it doesn't support the needed sasl
> mechanism and so isnt using the credentials, perhaps using anonymous
> instead or something. I'd suggest making sure you have the relevant
> cyrus sasl bits installed, e.g cyrus-sasl-plain.
> 
> You can see what is actually happening by running with env variable
> PN_TRACE_FRM=1 to emit a protocol trace to stdout.
> 

Thank you for your quick answer. It was indeed a problem with sasl
mechs. I figured out what the problem was and solved this problem.

> >
> > Regards,
> > Alexander
> >
> >
> >
> > My code so far (the relevant parts only)
> > There isn't much more actually. I'm still in the "exploring phase")
> > But from my understanding this should be enough for the login with a
> > different user.
> >
> > header file
> >
> > class listener : public proton::messaging_handler
> > {
> > ...
> > };
> >
> > code file:
> >
> > listener::listener (std::string servername, std::string port,
> > std::string user, std::string credentials) : m_servername
> > (servername), m_port (port), m_user (user), m_credentials
> > (credentials) { }
> >
> > void listener::on_container_start (proton::container &c)
> > {
> >   proton::connection_options co;
> >   m_url = m_servername + ":" + m_port + "/checkermq";
> >   co.user (m_user);
> >   co.password (m_credentials);
> >   co.sasl_enabled (true);
> >   m_sender = c.open_sender(m_url, co);
> > }
> >
> > In the main.cpp I start it with
> >
> >  listener l (servername, port, user, credentials);
> >  proton::container(l).run ();
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> > For additional commands, e-mail: users-help@qpid.apache.org
> >  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Help needed with first steps with libqpid-proton-cpp

Posted by Robbie Gemmell <ro...@gmail.com>.
On Thu, 18 Feb 2021 at 15:20, Alexander Nagel <al...@acwn.de> wrote:
>
> Hi folks,
>
> I'm trying to build a client for a rabbitmq broker.
> The client should send messages.
>
> I'm following the examples like
> https://github.com/apache/qpid-proton/blob/master/cpp/examples/simple_send.cpp
>
> My software stack is:
> Debian stable with package libqpid-proton-cpp12 Version 0.22.0
> g++ --version: g++ (Debian 8.3.0-6) 8.3.0
>

Note that Proton 0.22.0 is nearing a few years old. The current
release is 0.33.0.

>
> My problem:
> With the code below I can connect successfully to rabbitmq, but the
> user is always the default one (guest). When I change the queue name
> from "checkermq" to something else the queue is created also
> successfully.
>
> The code doesn't seem to accept the user and password, which I have
> defined in user and credentials. The user / password exists on the
> broker of course.
>
> * What do I miss here?
>

My first guess would be that it doesn't support the needed sasl
mechanism and so isnt using the credentials, perhaps using anonymous
instead or something. I'd suggest making sure you have the relevant
cyrus sasl bits installed, e.g cyrus-sasl-plain.

You can see what is actually happening by running with env variable
PN_TRACE_FRM=1 to emit a protocol trace to stdout.

>
> Regards,
> Alexander
>
>
>
> My code so far (the relevant parts only)
> There isn't much more actually. I'm still in the "exploring phase")
> But from my understanding this should be enough for the login with a
> different user.
>
> header file
>
> class listener : public proton::messaging_handler
> {
> ...
> };
>
> code file:
>
> listener::listener (std::string servername, std::string port,
> std::string user, std::string credentials) : m_servername (servername),
> m_port (port), m_user (user), m_credentials (credentials) { }
>
> void listener::on_container_start (proton::container &c)
> {
>   proton::connection_options co;
>   m_url = m_servername + ":" + m_port + "/checkermq";
>   co.user (m_user);
>   co.password (m_credentials);
>   co.sasl_enabled (true);
>   m_sender = c.open_sender(m_url, co);
> }
>
> In the main.cpp I start it with
>
>  listener l (servername, port, user, credentials);
>  proton::container(l).run ();
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org