Ok, looks like I have solved the problem. I had to add empty infinite loop in order to not stop the device.
I am able to setup connection to my local MQTT server - connection is fast, and durable (doesn't disconnect in general). However after I am connected M5 loose MQTT messages (doesn't receive them, or it doesn't handle them). At times it handles every message (lets say for about 10s), but later it doesn't handles any. Also at times it receive a message but it triggers the callback (the block of code) 5 - 10 s later.
My feeling is that M5 get's the messages but for some reason those are lost within the device.
I have similar setup with Wemos D1 (ESP8266) and there is no problem with MQTT.
I can only imagine that code written in plain C / C++ would be more robust, but I like the UI Flow env a lot and I would like to keep using it.
Do you have any hint what could be the reason of my problem and how could I try to fix it?