Basic EventStoreDB v20 example

I’m trying to give the new v20 of EventStore a go, but I’m having trouble getting connected.

I’m using the 20.6.0-rc-buster-slim Docker image in development mode (i.e. EVENTSTORE_DEV=True), and I’m using the new EventStore.Client.Grpc.Streams NuGet package and the following code as an example:

    public static void Main()
    {
        using var client = new EventStoreClient(
            new EventStoreClientSettings
            {
                ConnectivitySettings = new EventStoreClientConnectivitySettings
                {
                    Address = new Uri("https://localhost:1113/")                        
                }
            });

        var e = client.ReadAllAsync(Direction.Forwards, Position.Start)
            .ToArrayAsync().Result;
    }

However I’m getting an RPC exception on the ReadAllAsync line with the message ‘“Status(StatusCode=Internal, Detail=“Error starting gRPC call: The SSL connection could not be established”)”’.

I’m fairly sure this is something to do with the default security in this new release, but I’m a bit clueless as to what I should do to rectify it? I’m only looking to try the new APIs, so a workaround would be sufficient.

Thanks.

1 Like

Hey @jamiewinder_eventsto, you are right

The quickest way around this at the moment is to override the HttpClientHandler in EventStoreClientSettings with the following:

var settings = new EventStoreClientSettings {
	CreateHttpMessageHandler = () =>
		new HttpClientHandler {
			ServerCertificateCustomValidationCallback =
				(message, certificate2, x509Chain, sslPolicyErrors) => true
		},
	ConnectivitySettings = {
		Address = new Uri("https://localhost:2113")
	}
}; 

Thanks for your reply, though I’ve tried it and it doesn’t appear to make a difference. I still get the same error. I think I may have got the port wrong in my original post (1113 rather than 2113?) but I’ve tried both and neither seem to work. Port 2113 fails with a different error (Status(StatusCode=DeadlineExceeded, Detail=") so presumably that’s the wrong port.

It should be 2113, could it be possible that you are trying to read from the ‘$all’ stream without providing credentials?

For example:

	var e = await client.ReadAllAsync(
        Direction.Forwards, 
        Position.Start, 
        userCredentials: new UserCredentials("admin", "changeit")).ToArrayAsync();

Thanks again, I think I’m getting somewhere! I didn’t realise the credentials were now required for $all. Oddly adding those in the DefaultCredentials of the settings didn’t seem to make a difference, but adding them to the ReadAllAsync did.

I’m getting further, but I’m seeing a new exception now (again, on ReadAllAsync):

Google.Protobuf.InvalidProtocolBufferException: 'Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing.'

I can raise this on Github if needed as I think I’m beyond the point of getting connected!

What exact version of the client and server are you using? As this sounds like it might be a compatibility issue

For the server, I’m using the 20.6.0-rc-buster-slim image.

For the client, I was using [email protected] (from today, June 9th). I’ve just downgraded it to 20.6.0-rc, and so far that seems to be behaving more consistently now, including eliminating an intermittent ‘DeadlineExceeded’ error I was getting randomly.

Thanks for your help, really appreciated.

1 Like