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

Error: connect ECONNREFUSED #127

Open
kvrzh opened this issue Sep 17, 2024 · 1 comment
Open

Error: connect ECONNREFUSED #127

kvrzh opened this issue Sep 17, 2024 · 1 comment

Comments

@kvrzh
Copy link

kvrzh commented Sep 17, 2024

image
Hey, you have very good project, but i have some problem, this code will fail in 100% times, when you are not in LOL, then you enter the game.
Seems like session is not rdy to make requests...

Also, just a proposal, will be to trigger client.on('connect', () => {}) even on first start of game)

@EugeneWilson
Copy link
Contributor

This is caused because when the process is created the internal server has not yet had time to initialize and is not ready to take requests. This error on connection could be fixed by a loop calling the client and catching any ECONNREFUSED errors similar to what we did with web sockets.
Adding something like this in the authenticate function would prevent said error during startup

return new Promise<Credentials>(function testConnection(resolve, reject) {
    createHttp1Request({ method: 'GET', url: '/process-control/v1/process' }, credentials)
      .then(() => resolve(credentials))
      .catch((err) => {
        if (err.code === 'ECONNREFUSED') {
          setTimeout(testConnection, pollInterval, resolve, reject)
        } else {
          reject(err)
        }
      })
  })

I have no problem creating a PR that adds it if that's a feature @junlarsen would like. My question would be if it's a new connection option or added to awaitConnection

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

No branches or pull requests

2 participants