@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
I am using the hardware serial (pin 0 and 1 on Arduino Uno)
As @rafitc99 mentioned, you need to expand the Serila buffer, in the hardware serial also the Arduino board package implements a 64-byte ring buffer for send and receive on the hardware serial messages. So you need to change that to 256 as per your message length.
@rafitc99 The thing is that I am not using the SoftwareSerial library in receiving the message from the first microcontroller. I am using the hardware serial (pin 0 and 1 on Arduino Uno)