@salmanfaris Actually, I can't connect my NodeMCU device with the localhost server. I can establish a connection using the test.mosquitto.org server.
This is my required case: YouTube link