diff --git a/lib/ocpp/common/websocket/websocket_base.cpp b/lib/ocpp/common/websocket/websocket_base.cpp index 68a2137b09..3097a0b016 100644 --- a/lib/ocpp/common/websocket/websocket_base.cpp +++ b/lib/ocpp/common/websocket/websocket_base.cpp @@ -74,12 +74,13 @@ void WebsocketBase::disconnect(websocketpp::close::status::value code) { EVLOG_error << "Cannot disconnect a websocket that was not initialized"; return; } - if (code == websocketpp::close::status::normal) { - this->shutting_down = true; - } { std::lock_guard lk(this->reconnect_mutex); + if (code == websocketpp::close::status::normal) { + this->shutting_down = true; + } + if (this->reconnect_timer) { this->reconnect_timer.get()->cancel(); }