Updated to attempt reconnection on socket close