enable auto reconnect
This commit is contained in:
parent
096a285212
commit
2f2787fb98
@ -96,12 +96,13 @@ void AWSConnector::doConnect()
|
|||||||
m_client->setVersion(QMQTT::V3_1_1);
|
m_client->setVersion(QMQTT::V3_1_1);
|
||||||
m_client->setKeepAlive(30*60);
|
m_client->setKeepAlive(30*60);
|
||||||
m_client->setCleanSession(true);
|
m_client->setCleanSession(true);
|
||||||
|
m_client->setAutoReconnect(true);
|
||||||
m_client->connectToHost();
|
m_client->connectToHost();
|
||||||
|
|
||||||
connect(m_client, &QMQTT::Client::connected, this, &AWSConnector::onConnected);
|
connect(m_client, &QMQTT::Client::connected, this, &AWSConnector::onConnected);
|
||||||
connect(m_client, &QMQTT::Client::disconnected, this, &AWSConnector::onDisconnected);
|
connect(m_client, &QMQTT::Client::disconnected, this, &AWSConnector::onDisconnected);
|
||||||
connect(m_client, &QMQTT::Client::error, this, [](const QMQTT::ClientError error){
|
connect(m_client, &QMQTT::Client::error, this, [](const QMQTT::ClientError error){
|
||||||
qDebug() << "error" << error;
|
qCWarning(dcAWS()) << "An error happened in the MQTT transport" << error;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_client, &QMQTT::Client::subscribed, this, &AWSConnector::onSubscribed);
|
connect(m_client, &QMQTT::Client::subscribed, this, &AWSConnector::onSubscribed);
|
||||||
|
|||||||
@ -85,7 +85,6 @@ void CloudTransport::connectToCloud(const QString &token)
|
|||||||
|
|
||||||
void CloudTransport::remoteConnectionStateChanged(RemoteProxyConnection::State state)
|
void CloudTransport::remoteConnectionStateChanged(RemoteProxyConnection::State state)
|
||||||
{
|
{
|
||||||
qCDebug(dcCloud) << "Remote connection state changed" << state;
|
|
||||||
RemoteProxyConnection *proxyConnection = qobject_cast<RemoteProxyConnection*>(sender());
|
RemoteProxyConnection *proxyConnection = qobject_cast<RemoteProxyConnection*>(sender());
|
||||||
ConnectionContext context = m_connections.value(proxyConnection);
|
ConnectionContext context = m_connections.value(proxyConnection);
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ void CloudTransport::remoteConnectionStateChanged(RemoteProxyConnection::State s
|
|||||||
emit clientDisconnected(context.clientId);
|
emit clientDisconnected(context.clientId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qCDebug(dcCloud()) << state;
|
qCDebug(dcCloud()) << "Remote connection state changed" << state;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user