Authenticating with mosquittopp

698 views Asked by At

I am writing a simple mqtt client which will connect with a mosquitto broker.

I have used the C++ wrapper (mosquittopp) of the mosquitto library to write the mqtt client. However, I don't know how to authenticate a client with username and password through functions provided by the mosquittopp wrapper while connecting.

I am looking for the implementation of following client-tool command with the help of mosquittopp.

mosquitto_pub -m "testing" -t test -u sheheryar -P coke
1

There are 1 answers

0
Bertl Rockersau On

You can set user and password before connecting with

mosquittopp::username_pw_set(sUser, sPassword);