Fix indefinite event loop on connection error