0

I am trying to get the changes that have occurred in a couchDB database since the last time the code was executed. To do so, I have taken the following code from MYCouch library documentation. However, nothing is being printed and I am not sure why. I have made changes to the database between executions, but nothing is still printed and it is being exited with code 0. The problem is not with the database, since when I run a curl command for the changes from cmd, i get all the changes. So the error must be in the code

var cnInfo1 = new DbConnectionInfo("url", "mycompany")
        {
            Timeout = TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite)
        };

        using (var client = new MyCouchClient(cnInfo1))
        {
            var getChangesRequest = new GetChangesRequest
            {
                Feed = ChangesFeed.Continuous,
                Since = "1",
                Heartbeat = 3000
            };

            var cancellation = new CancellationTokenSource();
            try
            {
                await client.Changes.GetAsync(
                    getChangesRequest,
                    data =>
                    {
                        Console.WriteLine("Within the data callback.");
                        if (data != null)
                        {
                            Console.WriteLine("Data is not null.");
                            foreach (var change in data)
                            {
                                Console.WriteLine(change);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Data is null.");
                        }
                    },
                    cancellation.Token);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: " + ex.Message);
            }

0 Answers0