Added reconnection in failure method (for some reason close socket was not called)