close and re-open socket on error