diff --git a/src/clientpaho.cpp b/src/clientpaho.cpp index 1dcbf6a..9b492c3 100644 --- a/src/clientpaho.cpp +++ b/src/clientpaho.cpp @@ -377,10 +377,10 @@ std::int32_t ClientPaho::publish( const MqttMessage& message, int qos ) } std::unique_lock lck(m_mutex); - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || m_processPendingPublishes ) + if( ConnectionStatus::Connected != m_connectionStatus || m_processPendingPublishes ) { m_pendingPublishesReadyCV.wait(lck, [this]() { return !m_processPendingPublishes; }); - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus ) + if( ConnectionStatus::Connected != m_connectionStatus ) { LogDebug( "[ClientPaho::publish]", "Adding publish to pending queue." ); m_pendingPublishes.push_front( Publish{ qos, message } ); @@ -789,6 +789,8 @@ void ClientPaho::onConnectOnInstance( const std::string& cause ) void ClientPaho::onConnectSuccessOnInstance() { + m_processPendingPublishes = true; + LogDebug( "[ClientPaho::onConnectSuccessOnInstance]", std::string( m_clientId + " - onConnectSuccessOnInstance triggered." ) ); {