Adding support for reconnecting on error