Screen sharing stops working after disconnecting for about five minutes
My workaround for this problem is to login via ssh and kill loginwindow process:

sudo pkill loginwindow


This will allow to login via VNC then.