Decrypt or encrypt method not return response or throws exception

I use smack omemo in my Android Kotlin app, smack version 4.4.8, jdk version 21.

I have send message method. Sometimes it stopped in decrypt or encrypt method and not reached next line. It happend in other methods also(requestDeviceListUpdateFor), it not crash and throws an any exception. Only stop this line. ChatGpt say that it internally try to fetch device bundles or build sessions if they’re missing or This network operation can block if the recipient’s keys are unreachable or timeout occurs (e.g. user offline, bad server state).

But why it not return timeout exception? What is main problem? I share my send method only, it stop in encrypt method line -

fun sendGroupMessage(
    connection: XMPPTCPConnection,
    jsonModel: String,
    fromPhoneNumber: String,
    messageID: String?,
    body: String?,
    roomId: String,
    extensionElement: ExtensionElement? = null,
    isFirst: Boolean = true
) {
    CoroutineScope(Dispatchers.IO).launch {
        try {
            val mucJid = JidCreate.entityBareFrom(roomId.getRoomJIDfromRoomId())
            val manager = MultiUserChatManager.getInstanceFor(connection)
            val muc = manager.getMultiUserChat(mucJid)
            val omemoManager = XMPPOmemoManager.instance.omemoManager ?: return@launch

            if (!omemoManager.multiUserChatSupportsOmemo(muc)) {
                return@launch
            }

            val allAffiliateJids = getAllAffiliationJids2(muc)

                val encryptedMessage = omemoManager.encrypt(allAffiliateJids, jsonModel)

                val builder = StanzaBuilder
                    .buildMessage(messageID)
                    .to(mucJid)
                    .setBody(body)
                    .from(jidFromPhoneNumber(fromPhoneNumber))
                    .ofType(Message.Type.groupchat)
                    .addExtension(encryptedMessage.element)
                if (extensionElement != null) {
                    builder.addExtension(extensionElement)
                }

                StoreHint.set(builder)

                DeliveryReceiptRequest.addTo(builder)
                
                muc.sendMessage(builder)
           
        } catch (error: Throwable) {
            if ((error is IllegalArgumentException || error is NullPointerException) && isFirst) {
                XMPPOmemoManager.instance.setupOmemo(connection, context)
                sendGroupMessage(
                    connection,
                    jsonModel,
                    fromPhoneNumber,
                    messageID,
                    body,
                    roomId,
                    extensionElement,
                    false
                )
            } else if (error is XMPPErrorException && isFirst) {
                val subscribePresence = PresenceBuilder.buildPresence()
                    .ofType(Presence.Type.subscribe)
                    .to(JidCreate.entityBareFrom(roomId.getRoomJIDfromRoomId()))
                    .build()

                connection.sendStanza(subscribePresence)
                sendGroupMessage(
                    connection,
                    jsonModel,
                    fromPhoneNumber,
                    messageID,
                    body,
                    roomId,
                    extensionElement,
                    false
                )
            } else if (error is TimeoutCancellationException) {
                xmppConnectionRepository.reconnectXmpp()
                sendGroupMessage(
                    connection,
                    jsonModel,
                    fromPhoneNumber,
                    messageID,
                    body,
                    roomId,
                    extensionElement,
                    false
                )
            }
        }
    }
}

fun getAllAffiliationJids2(muc: MultiUserChat): Set<BareJid> {
    val allAffiliates = mutableSetOf<Affiliate>()
    val allAffiliateJids = mutableSetOf<BareJid>()

    try {
        val owners = muc.owners
        allAffiliates.addAll(owners)

        val admins = muc.admins
        allAffiliates.addAll(admins)

        val members = muc.members
        allAffiliates.addAll(members)

        allAffiliates.forEach {
            allAffiliateJids.add(it.jid.asBareJid())
        }

    } catch (e: Exception) {
        e.printStackTrace()
    }

    return allAffiliateJids
}