I will give this a go and see if it works services.AddEventStoreClient(settings => { settings = EventStoreClientSettings.Create(eventStoreConfiguration.ConnectionString); settings.DefaultCredentials = new UserCredentials(eventStoreConfiguration.Username, eventStoreConfiguration.Password); settings.CreateHttpMessageHandler = () => new SocketsHttpHandler { SslOptions = { RemoteCertificateValidationCallback = delegate { return true; } } }; });
System.InvalidOperationException
HResult=0x80131509
Message=Status(StatusCode=Internal, Detail=âRequest protocol âHTTP/1.1â is not supported.â)
Source=EventStore.Client
StackTrace:
at EventStore.Client.Interceptors.TypedExceptionInterceptor.AsyncStreamReader1.<MoveNext>d__4.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Grpc.Core.AsyncStreamReaderExtensions.<ReadAllAsync>d__01.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1.GetResult(Int16 token) at Grpc.Core.AsyncStreamReaderExtensions.<ReadAllAsync>d__01.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult() at EventStore.Client.EventStoreClient.ReadStreamResult.<>c__DisplayClass4_0.<<-ctor>g__GetStateInternal|0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at EventStore.Client.EventStoreClient.ReadStreamResult.<MoveNextAsync>d__10.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ValueTaskAwaiter1.GetResult()
at Foundation.Cqrs.Repository.EventStore.EventstoreEventStorageProvider.d__51.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Foundation.Cqrs.Repository.EventStore.EventstoreEventStorageProvider.<ReadStreamEventsForwardAsync>d__51.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Foundation.Cqrs.Repository.EventStore.EventstoreEventStorageProvider.d__51.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore1.GetResult(Int16 token)
at Foundation.Cqrs.Repository.EventStore.EventstoreEventStorageProvider.d__51.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token) at System.Runtime.CompilerServices.ValueTaskAwaiter1.GetResult()
at Foundation.Cqrs.Aggregate.SnapshotAggregateRoot2.<LoadFromHistory>d__15.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Foundation.Cqrs.Aggregate.SnapshotAggregateRoot2.d__15.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Foundation.Cqrs.Repository.SnapshotRepositoryDecorator.d__21.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at AccountService.Command.ApplicationService.HandleMessagesBaseHandler`2.d__4.MoveNext() in C:\connectbz\accountservice\src\Command\AccountService.Command.ApplicationService\HandleMessagesBaseHandler.cs:line 34
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
RpcException: Status(StatusCode=Internal, Detail=âRequest protocol âHTTP/1.1â is not supported.â)
There are two examples on that page and they are both docker compose, as the connection string esdb://localhost:2113?tls=false is only compatible with one of them. Youâll have to be more specific.
I started a node with your docker compose file, then wrote this small program:
internal class Program {
public static async Task<int> Main(string[] args) {
var provider = new ServiceCollection().AddSingleton(_ =>
new EventStoreClient(EventStoreClientSettings.Create("esdb://localhost:2113?tls=false")))
.BuildServiceProvider();
var client = provider.GetRequiredService<EventStoreClient>();
var e = await client.ReadAllAsync(Direction.Forwards, Position.Start, 1)
.FirstAsync();
await Console.Out.WriteLineAsync(new {
e.Event.EventStreamId,
e.Event.EventNumber,
e.Event.EventType
}.ToString());
return 0;
}
}
I omitted credentials here, as they will not be used when insecure=true. Here is the output:
Are you calling AppContext.SetSwitch in your code anywhere? The dotnet client will call AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true) to make unencrypted HTTP/2 work. Changing this to false can cause this error.
As Joao said, the gRPC client doesnât have the always-on connection, unlike the TCP connection. Hence the difference in the API semantics as we use the word Client. It connects when required only, similar to MongoDB client.