Catch IOExceptions in Connection.cs. 

A probable fix for #4083, #4423, #4501.