Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Receiving a disconnection (1) when connecting, to broker

Hi Ben,

I'm using the C++ library, so I'm calling loop_start();  You mention that I may not be sending keep alive messages... I have a 1 second timer that sends messages all of the time which should keep the connection alive, right?  Perhaps the way I'm making the connection and starting the loop needs to change?

mqtt::mqtt(char *_id, QString _host, int _port, int _keepalive) : mosquittopp(_id)
{
    // Initialization for mosquitto
    mosqpp::lib_init();

    // Basic configuration setup for mqtt class
    this->keepalive = _keepalive;
    this->id = _id;
    this->port = _port;
    this->host = _host;

    this->reconnect_delay_set(5, 30, true);

    // Non blocking connection to broker request
    connect_async(host.toStdString().c_str(), port, keepalive);

    // Start thread managing connection / publish / subscribe
    loop_start();
}


Back to the top