Bugfix: catch more exceptions to handle connection failure