Kernel returns in Connected mode after disconnecting during run

I am using Jupyter Lab on a container on AWS instances, connected using iframe to a web browser

When running long chunks of code, if the computer goes in to “sleep” the kernel is disconnected, and when it connects back it shows at the bottom left corner “Connected” instead of the “Busy” it was before.
Some of the times the Kernel is able to reconnect and keep running, but not always
There is an option to manually reconnect also

Is there some sort of configuration that I can add to help the Kernel reconnect and keep running from the same place ?

Thanks in advance