Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventStore.ClientAPI.Exceptions.ConnectionClosedException #72

Open
ghost opened this issue Nov 14, 2022 · 1 comment
Open

EventStore.ClientAPI.Exceptions.ConnectionClosedException #72

ghost opened this issue Nov 14, 2022 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Nov 14, 2022

EventStore v21.10.8
.NET 7

The code from your tutorial "TCP SDK 5.0.11 (.NET) - Connecting to EventStoreDB - Quick start" doesn't work. I have an error:
EventStore.ClientAPI.Exceptions.ConnectionClosedException: ‘Connection ‘ES-f2cffa2d-a4cc-4850-9976-0113bd272a81’ was closed.’

My code:

using EventStore.ClientAPI;
using System.Text;

var conn = EventStoreConnection.Create(new Uri("tcp://admin:changeit@localhost:1113"));
await conn.ConnectAsync();

var data = Encoding.UTF8.GetBytes("{\"a\":\"2\"}");
var metadata = Encoding.UTF8.GetBytes("{}");
var evt = new EventData(Guid.NewGuid(), "testEvent", true, data, metadata);

await conn.AppendToStreamAsync("test-stream", ExpectedVersion.Any, evt);

var streamEvents = await conn.ReadStreamEventsForwardAsync("test-stream", 0, 1, false);
var returnedEvent = streamEvents.Events[0].Event;

Console.WriteLine(
    "Read event with data: {0}, metadata: {1}",
    Encoding.UTF8.GetString(returnedEvent.Data),
    Encoding.UTF8.GetString(returnedEvent.Metadata)
);
@ghost ghost added the kind/bug label Nov 14, 2022
@alexeyzimarev
Copy link
Member

I think your server has TCP protocol disabled. When using v21.10, there's no need to use the legacy client. Move on to gRPC client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant