Fix some ANRs and force-close errors when connection failures occur.