diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 0d6472ff4d6933c75c626bfc94c7b23e3fa99e13..10213070ae6e752fa2ca3cc3ff40979d59c4450f 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -3039,7 +3039,14 @@ JamiAccount::sendMessage(const std::string& to,
     auto devices = std::make_shared<std::set<DeviceId>>();
 
     // Use the Message channel if available
-    auto* handler = static_cast<MessageChannelHandler*>(channelHandlers_[Uri::Scheme::MESSAGE].get());
+    std::unique_lock clk(connManagerMtx_);
+    auto* handler =static_cast<MessageChannelHandler*>(channelHandlers_[Uri::Scheme::MESSAGE].get());
+    if (!handler) {
+        clk.unlock();
+        if (!onlyConnected)
+            messageEngine_.onMessageSent(to, token, false, deviceId);
+        return;
+    }
     const auto& payload = *payloads.begin();
     MessageChannelHandler::Message msg;
     msg.t = payload.first;
@@ -3047,7 +3054,9 @@ JamiAccount::sendMessage(const std::string& to,
     auto device = deviceId.empty() ? DeviceId() : DeviceId(deviceId);
     if (deviceId.empty()) {
         bool sent = false;
-        for (const auto &conn: handler->getChannels(toUri)) {
+        auto conns = handler->getChannels(toUri);
+        clk.unlock();
+        for (const auto &conn: conns) {
             if (MessageChannelHandler::sendMessage(conn, msg)) {
                 devices->emplace(conn->deviceId());
                 sent = true;
@@ -3060,7 +3069,8 @@ JamiAccount::sendMessage(const std::string& to,
             });
         }
     } else {
-        if (const auto &conn = handler->getChannel(toUri, device)) {
+        if (auto conn = handler->getChannel(toUri, device)) {
+            clk.unlock();
             if (MessageChannelHandler::sendMessage(conn, msg)) {
                 if (!onlyConnected)
                     runOnMainThread([w = weak(), to, token, deviceId]() {
@@ -3071,6 +3081,8 @@ JamiAccount::sendMessage(const std::string& to,
             }
         }
     }
+    if (clk)
+        clk.unlock();
 
     std::unique_lock lk(sipConnsMtx_);
     for (auto& [key, value]: sipConns_) {