PrestaShopCorp / nestjs-geteventstore

MIT License
34 stars 8 forks source link

Eventstore doesnt re-connect properly after disconnection #74

Closed kodeine closed 3 years ago

kodeine commented 3 years ago

So i put down eventstore (docker) while nestjs app is running, i re-run docker and eventstore is up. nestjs app says connected as well but in reality its not connected, see below.

[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStoreBus] Persistent subscription "adgroup" on stream $ce-ad_groups created ! {"resolveLinkTos":true,"minCheckPointCount":1} - {"service":"service-ad-group"} +45ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStoreBus] Persistent subscription "adgroup" on stream $ce-campaign created ! {"resolveLinkTos":true,"minCheckPointCount":1} - {"service":"service-ad-group"} +1ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStoreBus] Connecting to persistent subscription "adgroup" on stream $ce-campaign - {"service":"service-ad-group"} +8ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStoreBus] Connecting to persistent subscription "adgroup" on stream $ce-ad_group - {"service":"service-ad-group"} +27ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStoreBus] Connecting to persistent subscription "adgroup" on stream $ce-ad_groups - {"service":"service-ad-group"} +0ms
[Nest] 5589   - 09/08/2021, 7:26:40 PM   [EventStoreCore] Subscription started. +486ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-campaign! - {"service":"service-ad-group"} +150ms
[Nest] 5589   - 09/08/2021, 7:26:40 PM   [EventStoreCore] Subscription started. +6ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-ad_group! - {"service":"service-ad-group"} +5ms
[Nest] 5589   - 09/08/2021, 7:26:40 PM   [EventStoreCore] Subscription started. +4ms
[NestWinston] Info  9/8/2021, 7:26:40 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-ad_groups! - {"service":"service-ad-group"} +12ms
Enabling inline tracing for this federated service. To disable, use ApolloServerPluginInlineTraceDisabled.
[NestWinston] Info  9/8/2021, 7:26:45 PM [NestApplication] Nest application successfully started - {"service":"service-ad-group"} +5s
[Nest] 5589   - 09/08/2021, 7:26:46 PM   [EventStoreCore] TcpPackageConnection: connection [{"host":"192.168.1.170","port":1113}, L{"host":"192.168.1.214","port":62493}, 732befcb-9265-413b-b33b-151ee028a2ed] was closed with error: Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (node:net:449:14)
    at TcpConnection.module.exports.TcpConnection._trySend (/Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:2844:21)
    at TcpConnection.module.exports.TcpConnection.enqueueSend (/Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:2828:8)
    at TcpPackageConnection.module.exports.TcpPackageConnection.enqueueSend (/Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:2639:20)
    at EventStoreConnectionLogicHandler.module.exports.EventStoreConnectionLogicHandler._handleTcpPackage (/Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:2226:22)
    at /Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:1821:10
    at Immediate._handlers.<computed> [as _onImmediate] (/Users/user/Project/service-ad-group/node_modules/node-eventstore-client/lib/dist.js:2474:7)
    at processImmediate (node:internal/timers:466:21) +5202ms
[NestWinston] Warn  9/8/2021, 7:26:46 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-campaign dropped connectionClosed : Error: Connection was closed. - {"service":"service-ad-group"} +472ms
[NestWinston] Warn  9/8/2021, 7:26:46 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-ad_group dropped connectionClosed : Error: Connection was closed. - {"service":"service-ad-group"} +7ms
[NestWinston] Warn  9/8/2021, 7:26:46 PM [EventStore] Connected to persistent subscription adgroup on stream $ce-ad_groups dropped connectionClosed : Error: Connection was closed. - {"service":"service-ad-group"} +1ms
[Nest] 5589   - 09/08/2021, 7:26:56 PM   [EventStoreCore] TcpPackageConnection: connected to [{"host":"192.168.1.170","port":1113}, L{"host":"192.168.1.214","port":62714}, 7a3bb650-3a03-4d07-ac2f-5bba1ff2afbc]. +10291ms
[Nest] 5589   - 09/08/2021, 7:26:56 PM   [EventStoreCore] TcpConnection: successfully connected to {"host":"192.168.1.170","port":1113} +1ms
[NestWinston] Info  9/8/2021, 7:26:56 PM [EventStore] Connection to EventStore established! - {"service":"service-ad-group"} +10s
[Nest] 5589   - 09/08/2021, 7:26:56 PM   [EventStoreCore] Connected to eventstore +25ms

image

the green ones in image, i manually re-run the nestjs apps. Once i restart the apps only then missed events are replayed, not upon re-connect.

AlexandreDecollas commented 3 years ago

Hi Kodeine,

Thank you for your interest!

The connector is currently been updated these days, and soon a v5 will be release, that will be compatible with the last version of ES, using gRPC, so this shouldn't be an issue anymore after that.

kodeine commented 3 years ago

Hello @AlexandreDecollas , I am aware you u guys are working on a newer client version and i'm very excited to start using it. The problem right now is i have a lot of services using the older version of this package and it will take me some time to migrate to the newer version. In the meantime, is it possible to push a hotfix patch for this disconnection issue? I would be really thankful.

i am using "nestjs-geteventstore": "1.6.4",

Update: actually, i just reviewed the latest merge and it seems its easier to update my services to use the newest version and we get the taste of eventstore 20 too.