Sample code gives EventStore.ClientAPI.Exceptions.ConnectionClosedException: 'Connection was closed.'

Hello

I am new to EventStore and wanted to try it out hence I went to the docs and used some of the sample code but immediately ended up with a connection issue.

Server setup:
Single node docker-compose from:

https://developers.eventstore.com/server/v21.10/installation.html#use-docker-compose

version: "3.4"

services:
  eventstore.db:
    image: eventstore/eventstore:21.10.0-buster-slim
    environment:
      - EVENTSTORE_CLUSTER_SIZE=1
      - EVENTSTORE_RUN_PROJECTIONS=All
      - EVENTSTORE_START_STANDARD_PROJECTIONS=true
      - EVENTSTORE_EXT_TCP_PORT=1113
      - EVENTSTORE_HTTP_PORT=2113
      - EVENTSTORE_INSECURE=true
      - EVENTSTORE_ENABLE_EXTERNAL_TCP=true
      - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true
    ports:
      - "1113:1113"
      - "2113:2113"
    volumes:
      - type: volume
        source: eventstore-volume-data
        target: /var/lib/eventstore
      - type: volume
        source: eventstore-volume-logs
        target: /var/log/eventstore

volumes:
  eventstore-volume-data:
  eventstore-volume-logs:

Client setup:
.NET nuget EventStore.Client v21.2.2
Transaction sample from:

https://developers.eventstore.com/clients/dotnet/5.0/appending.html#transactions

static EventData CreateSample(int i)
{
    var sampleObject = new { a = i };
    var data = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(sampleObject));
    var metadata = Encoding.UTF8.GetBytes("{}");
    var eventPayload = new EventData(
        Guid.NewGuid(), 
        "event-type", 
        true, 
        data, 
        metadata
    );
    return eventPayload;
}

public static async Task Main()
{
    var conn = EventStoreConnection.Create(new Uri("tcp://admin:changeit@localhost:1113"));
    await conn.ConnectAsync();

    using var transaction = 
        await conn.StartTransactionAsync("newstream", ExpectedVersion.Any);

    await transaction.WriteAsync(CreateSample(1));
    await transaction.WriteAsync(CreateSample(2));
    await conn.AppendToStreamAsync("newstream", ExpectedVersion.Any, CreateSample(3));
    await transaction.WriteAsync(CreateSample(4));
    await transaction.WriteAsync(CreateSample(5));
    await transaction.CommitAsync();
}

Observations:
In the browser dashboard I do not see any connections being made when the conn.ConnectAsync() part is executed which I find odd?

When the conn.StartTransactionAsync(…) part executes I immediately see a connection in the dashboard however every couple seconds the id and port changes. It seems like reconnects continuously occurs.
It continues on like that for close to a minute before given the exception mentioned in topic:

EventStore.ClientAPI.Exceptions.ConnectionClosedException: ‘Connection ‘ES-7a6288d3-005c-4f3a-a1a5-1e3db12e1779’ was closed.’

Anyone who can help out?

is the problem solved? it is also my issue

Not an actual solution to the specified issue, but we are working with esdb since a couple of weeks. As far as we understood the tcp is obsolete and it is prefered to start using grpc already.