Exception was catching error codes instead of an exception class

I changed the except clause to catch IOError since catching the int error codes does not work. The same error codes are then checked to initiate a retry and reconnect.