TimelordUK / jspurefix

native typescript FIX engine
MIT License
60 stars 28 forks source link

Process crash if connection can't be made #44

Closed hmvs closed 2 years ago

hmvs commented 2 years ago

The node process crashed if a socket connection can't be made.

Error: connect ETIMEDOUT 127.0.0.1:7001 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)

TimelordUK commented 2 years ago

There is a setting in application section of json which is a resilient book. This will use recovering tcp initiation which does loop for a timeout period but even that eventually will stop after a period. This one will also attempt to reconnect if you lose tcp connection. I don’t know your exact requirement but this may help.

hmvs commented 2 years ago

Using RecoveringTcpInitiator actually solves the issue, however, I am losing control of retrying by myself. And I still believe TcpInitiator should not crash the app but should reject the Promise if it can't connect.

hmvs commented 2 years ago

I was wrong.RecoveringTcpInitiator won't help. Without the line in PR, the app crashes

creating an application session with DI token FixSession. (module=StagingClient:RecoveringTcpInitiator) current state Idle (24) moves to DisconnectedNoConnectionToday (1) (module=StagingClient:FixSession) connect: start initiator timeout 60 (module=StagingClient:RecoveringTcpInitiator) current state DisconnectedNoConnectionToday (1) moves to InitiateConnection (5) (module=StagingClient:FixSession) connecting with timeout 60 (module=StagingClient:TcpInitiator) tryConnect 127.0.0.1:7001 (module=StagingClient:TcpInitiator) Error: connect ETIMEDOUT 127.0.0.1:7001 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -60, code: 'ETIMEDOUT', syscall: 'connect', address: '127.0.0.1', port: 7001 } [nodemon] app crashed - waiting for file changes before starting...

hmvs commented 2 years ago

@TimelordUK thanks for the merging, however it requires more fixing. Looks like when connection timeout promise rejection is happening it is not handled properly, and the app crashes. I wanted to write a unit test on tcp-initiator however I haven't found an easy way.

hmvs commented 2 years ago

Hi @TimelordUK. I finally found the place which caused the app to crash. There was a mix of promise and async style and as a result, we had a lost promise there. Have a look at #46

hmvs commented 2 years ago

@TimelordUK thank you for merging the PR. Any ideas when you plan to release a new version?

TimelordUK commented 2 years ago

done 2.1.0 - thanks for all your hard work in this.

On Fri, 5 Aug 2022 at 13:57, Vadym Kurachevskyi @.***> wrote:

@TimelordUK https://github.com/TimelordUK thank you for merging the PR. Any ideas when you plan to release a new version?

— Reply to this email directly, view it on GitHub https://github.com/TimelordUK/jspurefix/issues/44#issuecomment-1206428037, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXWJG76JMZ2NG6NN4ANVCTVXUFVFANCNFSM55AYTGYA . You are receiving this because you were mentioned.Message ID: @.***>