Rescue Errno::ETIMEDOUT from connect(2)

Also fix typo
Add check for nil