Thing.handle blocking when connected to WiFi but not to server

I have problem with thing.handle function when the ESP module has WiFi but can’t reach server as our internet service provider is offline.
I logged if wifi disconnected ever meanwhile but it never did.
But the WAN Internet Provider connection is quite unreliable.

Thanks for help in advance

And the problem is???