Added auto-reconnect on socket close.