Fixed crash when connection fails