EventStore / EventStore-Client-Dotnet

Dotnet Client SDK for the Event Store gRPC Client API written in C#
Other
138 stars 38 forks source link

RpcException When Using AppendToStreamAsync From Windows #299

Closed robbytarigan closed 1 month ago

robbytarigan commented 2 months ago

Describe the bug RpcException When Using AppendToStreamAsync From Windows.

To Reproduce Steps to reproduce the behavior:

  1. Use Windows 11 OS
  2. Use latest package at the time of writing which is EventStore.Client.Streams version 23.2.1
  3. Run the quick start example from https://github.com/EventStore/EventStore-Client-Dotnet/blob/master/samples/quick-start/Program.cs

Expected behavior The stream is appended

Actual behavior RpcException was thrown with error below:

Grpc.Core.RpcException: Status(StatusCode="DeadlineExceeded", Detail="")
   at EventStore.Client.Interceptors.TypedExceptionInterceptor.<>c__DisplayClass1_0.<.ctor>b__0(RpcException rpcEx)
   at EventStore.Client.Interceptors.RpcExceptionConversionExtensions.<>c__DisplayClass1_0`1.<Apply>b__0(Task`1 t)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at EventStore.Client.GrpcServerCapabilitiesClient.GetAsync(CallInvoker callInvoker, CancellationToken cancellationToken)
   at EventStore.Client.EventStoreClientBase.GetChannelInfoExpensive(ReconnectionRequired reconnectionRequired, Action`1 onReconnectionRequired, IChannelSelector channelSelector, CancellationToken cancellationToken)
   at EventStore.Client.SharingProvider`2.FillBoxAsync(TaskCompletionSource`1 box, TInput input)
   at EventStore.Client.TaskExtensions.WithCancellation[T](Task`1 task, CancellationToken cancellationToken)
   at EventStore.Client.EventStoreClientBase.GetChannelInfo(CancellationToken cancellationToken)
   at EventStore.Client.EventStoreClient.<CreateStreamAppender>g__GetCall|17_0()
   at EventStore.Client.EventStoreClient.StreamAppender.Receive()
   at EventStore.Client.EventStoreClient.AppendToStreamAsync(String streamName, StreamState expectedState, IEnumerable`1 eventData, Action`1 configureOperationOptions, Nullable`1 deadline, UserCredentials userCredentials, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args)

Config/Logs/Screenshots The event store server was run using docker with command below

docker run --rm --name esdb-node -it -p 2113:2113 -p 1113:1113 eventstore/eventstore:latest --insecure --run-projections=All --enable-atom-pub-over-http

EventStore details

Additional context Add any other context about the problem here.

w1am commented 2 months ago

Does this happen constantly? I'm on Windows 11 too and unable to reproduce this error. Which target framework are you on?

bartelink commented 2 months ago

Also worth mentioning whether other operations work etc - i.e. is it simply a firewall-driven timeout due to how your environment is configured? ESDB is not a low usage system so it's not a matter of SELECT being broken. Are you sure you'e configuring the server to serve on the correct ports (for gRPC, which your code is using; not TCP, which is dead)?

robbytarigan commented 2 months ago

I'm not sure about what configuration available. I follow the docker run instruction which use arguments --insecure--run-projections=All --enable-atom-pub-over-http and the port is mapped the same into my local machine.

I've tried the read operation ReadStreamAsync which also failed with similar error

Grpc.Core.RpcException: Status(StatusCode="DeadlineExceeded", Detail="")

robbytarigan commented 2 months ago

Does this happen constantly? I'm on Windows 11 too and unable to reproduce this error. Which target framework are you on?

This happen constantly. I target .NET 8.0

The project content is below

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.2.1" />
    </ItemGroup>

</Project>
josephcummings commented 2 months ago

Hi @robbytarigan, I have tried this too and have been unable to recreate the problem.

Would it be possible for you to provide a small reproducible example via a public GitHub repository? Preferably using docker compose.

Thanks in advance!

robbytarigan commented 2 months ago

Hi @josephcummings

I don't think I can reproduce it using docker compose because it does not support mixed windows and linux containers. I even cannot keep the evenstore server running when I switched into windows container. Probably I will need a bit more complex setup to make it reproducible, so need to think different idea.

josephcummings commented 2 months ago

@robbytarigan no problem, if it is just the sample you are running as-is then my request for a composable reproducible example likely won't prove useful - I misread the second bullet point in the repro steps and assumed you may have a custom application where you are experiencing the issue, too, my apologies.

Regarding Windows vs Linux containers, the eventstore:latest image is a linux image so your Docker would need to be configured to run linux containers on windows desktop for the docker run ... command you are using to work.

Please can you try running the same docker run command but in detached mode as per below, then monitor the health of the container and let me know if you can see the container reach healthy status?

docker run -d --rm --name esdb-node -it -p 2113:2113 -p 1113:1113 eventstore/eventstore:latest --insecure --run-projections=All --enable-atom-pub-over-http

Assuming everything is OK, you should see something like the below:

image

If possible, it would be handy to have a dump of the container/server logs? Healthy or not.

robbytarigan commented 2 months ago

The eventstore server is healthy. Please see the screenshot below image

Please also see the server logs attached. server.log

w1am commented 2 months ago

@robbytarigan Does the event appear in the stream browser?

robbytarigan commented 2 months ago

@w1am No, the event does not appear

w1am commented 2 months ago

@robbytarigan I suggest testing a simple operation using a different client, such as the Node.js client or with a different server version (lts). If you continue to encounter the same issue, the problem is likely with your environment.

Have you also considered increasing the timeout to see if it makes a difference?

var settings = EventStoreClientSettings.Create(connectionString); 
settings.ConnectivitySettings.KeepAliveTimeout = TimeSpan.FromMinutes(1); 
robbytarigan commented 2 months ago

@w1am I followed your suggestion to use NodeJS client example, and there is no problem with it. I put the screenshot for this operation here

image

I also try KeepAliveTimeout settings as suggested and it still gives the same error.

w1am commented 2 months ago

@robbytarigan Can you try with this connection string in the dotnet client instead

esdb://admin:changeit@127.0.0.1:2113?tls=false&tlsVerifyCert=false

The difference is that I replaced localhost with 127.0.0.1

Remove the previous keepAliveTimeout option I proposed initially

robbytarigan commented 2 months ago

@w1am I cannot believe it works by replacing localhost with 127.0.0.1. I can see the stream is stored too now. I'll use 127.0.0.1 during local development then. Thank you!