fix retry connect error when call end()