MQTT unable to subscribe value from publish

#include <WiFi.h>
#include <PubSubClient.h>
#include <UniversalTelegramBot.h>
#include <WiFiClientSecure.h>
const char* ssid = "";
const char* password =  "";
const char* mqttServer = "test.mosquitto.org";
const int mqttPort = 1883;
// ------- Telegram config ----------
#define BOT_TOKEN ""  // your Bot Token (Get from Botfather)
#define CHAT_ID "" // Chat ID of where you want the message to go (You can use MyIdBot to get the chat ID)
long Bot_lasttime;
int Bot_mtbs = 1000; //mean time between scan messages
int Distance = 0;
String dist;
int bulk_messages_mtbs = 10000; // testing to delay 6sec to detecting another distance and which message been sent .

WiFiClient espClient;
PubSubClient client(espClient);

UniversalTelegramBot bot(BOT_TOKEN, espClient);
String ipAddress = "";

volatile bool telegramButton1PressedFlag = false;
volatile bool telegramButton2PressedFlag = false;

void callback(char* topic, byte* payload, unsigned int length) {
 
  Serial.print("Message arrived in topic: ");
  Serial.println(topic);
 
  Serial.println("Message:");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
 
  Serial.println();
  Serial.println("-----------------------");
 
}
 
void setup() {
 
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
  Serial.println("Connected to the WiFi network");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  client.setServer(mqttServer, mqttPort);
  client.setCallback(callback);
  
  while (!client.connected()) {
    Serial.println("Connecting to MQTT...");
 
    if (client.connect("ESP32Client")) {
 
      Serial.println("connected Server");  
 
    } else {
 
      Serial.print("failed with state ");
      Serial.print(client.state());
      delay(2000);
 
    }
  }
 
  client.subscribe("smartdevice");

}  
  void sendTelegramMessage1() {
    String message = "Pantry soap dispenser empty! Please top-up!";
    if(bot.sendMessage(CHAT_ID, message, "Markdown")){
      Serial.println("TELEGRAM Message 1 Successfully sent");
  }
    telegramButton1PressedFlag = false;
}
  void sendTelegramMessage2() {
    String message2 = "Pantry soap dispenser Full! Please top-up!";
    if(bot.sendMessage(CHAT_ID, message2, "Markdown")){
      Serial.println("TELEGRAM Message 2 Successfully sent");
  }
    telegramButton1PressedFlag = false;
}
void loop() {
  client.loop();
    Serial.println(client.loop());
    dist = String(Distance);
      if(Distance >80){
          sendTelegramMessage1();
}     else{
          sendTelegramMessage2();
}
}

The statement from serial monitor shown that the client.loop(); function as 0 , it means that it did not been function for subscribe. Any one seems any mistake from this code?

    String message = "Pantry soap dispenser empty! Please top-up!";
    String message2 = "Pantry soap dispenser Full! Please top-up!";

When the dispenser is empty, it needs to be filled. When it is full, it needs to be filled. You'll never be satisfied with the level of soap, will you?

  client.loop();
    Serial.println(client.loop());

Why are you calling loop() twice? Have you investigated what loop() returns, and what 0 means?