Following the “Hands-on DDD with .NET Core” by Alexey Zimarev, I am going through the code examples, and coding the same concepts on a different domain. Trying to run the dockerized example, with one .NET Core API and Event Store database, I am able to start everything correctly, I go to Event Store UI app, and there I can see that my API managed to initialize the connection to the Event Store:
However, when I try to connect to the Event Store from the Controller/Service code, trying to read event stream, I am getting an "error": "Item Operation ReadEventOperation... reached retries limit : 10 ... "stackTrace": " at EventStore.ClientAPI.Internal.EventStoreNodeConnection.ReadEventAsync ...
My appsettings:
"eventStore": {
"connectionString": "ConnectTo=tcp://admin:[email protected]:1113; DefaultUserCredentials=admin:changeit; HeartBeatTimeout=500"
docker-compose.yml eventstore service:
services:
eventstore:
container_name: esskipass-eventstore
image: eventstore/eventstore
command: --dev --enable-external-tcp --ext-ip=0.0.0.0 --int-ip=0.0.0.0 --disable-external-tcp-tls
environment:
- EVENTSTORE_CLUSTER_SIZE=1
- EVENTSTORE_INT_TCP_PORT=1112
- EVENTSTORE_EXT_TCP_PORT=1113
- EVENTSTORE_INT_HTTP_PORT=2112
- EVENTSTORE_EXT_HTTP_PORT=2113
- EVENTSTORE_DEV=true
ports:
- "1112:1112"
- "1113:1113"
- "2112:2112"
- "2113:2113"
...
and Event Store logs:
...
[ 1,17,20:59:11.046,INF] External TCP connection accepted: [Normal, "172.20.0.1:54850", L"172.20.0.2:1113", {81629828-c448-49a0-8e99-6fb8803f3928}].
[ 1,21,20:59:12.509,INF] ES "TcpConnection" closed [20:59:12.508: N"172.20.0.1:54850", L"172.20.0.2:1113", {81629828-c448-49a0-8e99-6fb8803f3928}]:Received bytes: 312, Sent bytes: 0
[ 1,21,20:59:12.509,INF] ES "TcpConnection" closed [20:59:12.509: N"172.20.0.1:54850", L"172.20.0.2:1113", {81629828-c448-49a0-8e99-6fb8803f3928}]:Send calls: 0, callbacks: 0
[ 1,21,20:59:12.509,INF] ES "TcpConnection" closed [20:59:12.509: N"172.20.0.1:54850", L"172.20.0.2:1113", {81629828-c448-49a0-8e99-6fb8803f3928}]:Receive calls: 2, callbacks: 2
[ 1,21,20:59:12.509,INF] ES "TcpConnection" closed [20:59:12.509: N"172.20.0.1:54850", L"172.20.0.2:1113", {81629828-c448-49a0-8e99-6fb8803f3928}]:Close reason: [Success] "Socket closed"
[ 1,21,20:59:12.510,INF] Connection '"external-normal"""' ["172.20.0.1:54850", {81629828-c448-49a0-8e99-6fb8803f3928}] closed: Success.
[ 1, 6,20:59:12.511,DBG] Persistent subscription lost connection from "172.20.0.1:54850"
[ 1,21,20:59:12.718,INF] External TCP connection accepted: [Normal, "172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}].
[ 1,10,20:59:17.735,DBG] Closing connection '"external-normal"""' ["172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}] cleanly." Reason: HEARTBEAT TIMEOUT at msgNum 1"
[ 1,10,20:59:17.735,INF] ES "TcpConnection" closed [20:59:17.735: N"172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}]:Received bytes: 312, Sent bytes: 22
[ 1,10,20:59:17.735,INF] ES "TcpConnection" closed [20:59:17.735: N"172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}]:Send calls: 1, callbacks: 1
[ 1,10,20:59:17.735,INF] ES "TcpConnection" closed [20:59:17.735: N"172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}]:Receive calls: 2, callbacks: 1
[ 1,10,20:59:17.735,INF] ES "TcpConnection" closed [20:59:17.735: N"172.20.0.1:54870", L"172.20.0.2:1113", {45da7e67-2f2b-422b-a1eb-28339c685205}]:Close reason: [Success] "HEARTBEAT TIMEOUT at msgNum 1"
[ 1,10,20:59:17.736,INF] Connection '"external-normal"""' ["172.20.0.1:54870", {45da7e67-2f2b-422b-a1eb-28339c685205}] closed: Success.
[ 1,21,20:59:17.736,DBG] Persistent subscription lost connection from "172.20.0.1:54870"
[ 1, 6,20:59:17.912,INF] External TCP connection accepted: [Normal, "172.20.0.1:54878", L"172.20.0.2:1113", {5c21a809-26be-42b7-b979-b2e6532d508d}].
[ 1,10,20:59:22.926,DBG] Closing connection '"external-normal"""' ["172.20.0.1:54878", L"172.20.0.2:1113", {5c21a809-26be-42b7-b979-b2e6532d508d}] cleanly." Reason: HEARTBEAT TIMEOUT at msgNum 1"
[ 1,10,20:59:22.927,INF] ES "TcpConnection" closed [20:59:22.926: N"172.20.0.1:54878", L"172.20.0.2:1113", {5c21a809-26be-42b7-b979-b2e6532d508d}]:Received bytes: 312, Sent bytes: 22
...
First I’ve found out that without command: --dev --enable-external-tcp --ext-ip=0.0.0.0 --int-ip=0.0.0.0 --disable-external-tcp-tls
my Event Store wouldn’t start, TCP port would start disabled. Then I’ve tried with setting different ports, HeartbeatTimeout, HeartbeatInterval …, and some other connection settings customizations. Event Store and event sourcing are a new ground to me, so it may be that I am missing some basic customization here.
(I’ve actually asked the same question on Stackoverflow, but only after that I found about EventStore discuss forum)
Appreciate any help or advice.