first commit
This commit is contained in:
parent
0e8ced1624
commit
15433a861e
@ -37,7 +37,14 @@ void MQTTClient::connect()
|
|||||||
.password(config_.password)
|
.password(config_.password)
|
||||||
.finalize();
|
.finalize();
|
||||||
|
|
||||||
client_->connect(connOpts)->wait();
|
auto tok = client_->connect(connOpts); // 异步连接
|
||||||
|
if (!tok->wait_for(std::chrono::seconds(2))) // 设置超时
|
||||||
|
{
|
||||||
|
LOG_WARN("[MQTTClient] Connect timed out to broker: " + config_.server_ip);
|
||||||
|
startReconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connected_ = true;
|
connected_ = true;
|
||||||
reconnect_active_ = false;
|
reconnect_active_ = false;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user