Skip to content

Commit

Permalink
Only call disconnect when Client is connected to a broker
Browse files Browse the repository at this point in the history
  • Loading branch information
HpLightcorner committed Apr 8, 2022
1 parent 0ae0bba commit 75ac993
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mqtt-plugin/src/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ void Service::disconnect()
std::lock_guard<std::mutex> lock(m_mtx);
if (m_client)
{
m_client->disconnect(100)->wait();
m_client->disable_callbacks();
m_client.reset();
if (m_client->is_connected())
{
m_client->disconnect(100)->wait();
m_client->disable_callbacks();
m_client.reset();
}
}
}

Expand Down

0 comments on commit 75ac993

Please sign in to comment.