shubhamranjan / dotnet-etcd

A C# .NET (dotnet) GRPC client for etcd v3 +
MIT License
266 stars 60 forks source link

Exception while opening a watch on etcd grpc-proxy #185

Open marcotod1410 opened 1 year ago

marcotod1410 commented 1 year ago

Describe the bug The creation of a watch client raises a RpcException (context canceled) when opening a watch on a node. This happens only when connecting to a grpc-proxy node (reference). When connecting to a single node, or setting multiple comma-separated endpoints, the exception does not occur and the watch works regularly.

To Reproduce Run the following code in a console application:

using Etcdserverpb;
using System;
using System.Threading.Tasks;

namespace TestEtcdWatchException
{
    internal class Program
    {
        static async Task Main(string[] args)
        {
            var connection = new dotnet_etcd.EtcdClient("http://127.0.0.1:23790");
            await connection.WatchAsync(new WatchRequest()
            {
                CreateRequest = new WatchCreateRequest()
                {
                    Key = Google.Protobuf.ByteString.CopyFromUtf8("/test-key")
                }
            }, evt =>
            {
                Console.WriteLine($"Received watch response with watch id {evt.WatchId}");
                foreach (var e in evt.Events)
                {
                    Console.WriteLine("\tReceived event " + e.Type);
                }
            });
        }
    }
}

Additional context Testing on dotnet_etcd version 6.0.1, etcd version is 3.4.18. etcd grpc-proxy is started with the following command (assuming there is a cluster with three nodes): ./etcd grpc-proxy start --endpoints "http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379" --listen-addr "127.0.0.1:23790"