IOManager connect and accept failure handling. Fixes #3035

Cherry-picked from release-2.1.

I also reversed a small change (highlighted in a comment below) that I'd accidentally made in 2.1.