In my case, I was trying to create Amason Machine Image (AMI), and by default aws reboot the instance, which cause a disconnection.