Handle some IOExceptions, to support keep-alive mode.