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

Intermittent RestError: read ECONNRESET Error when Sending Messages to OpenAI Deployment #46

Open
ltara opened this issue Sep 30, 2023 · 0 comments

Comments

@ltara
Copy link

ltara commented Sep 30, 2023

I am facing an intermittent issue with the @azure/[email protected] library using the [email protected]. While attempting to send messages to an OpenAI deployment, I sporadically encounter the ECONNRESET error. Despite multiple attempts, this problem persists. Below is my code snippet along with the error message:

code :

for (let attempt = 0, keyIdx = 0; attempt < retries; attempt++, keyIdx++) {
  const openai = await this.createAPI();

  const messages = [
    {
      role: 'system',
      content: prompt,
    },
    { role: 'user', content: content },
  ];
  try {
    let res = '';
    const result = await openai.getChatCompletions(
      OPENAI_DEPLOYMENT_ID,
      messages,
    );
    for (const choice of result.choices) {
      console.log(choice.message.content);
      res += choice.message.content;
    }

    return res;
  } catch (error) {
    if (attempt === retries - 1) {
      console.log('Failed after maximum attempts', error);
      throw error;
    }
  }
}

Error Message:

Failed after maximum attempts RestError: read ECONNRESET 
{
  "name": "RestError",
  "code": "ECONNRESET",
  "request": {
    "url": "https://[xxx].openai.azure.com/openai/deployments/[openai-model]/chat/completions?api-version=2023-08-01-preview",
    "headers": {
      // Request headers
    },
    "method": "POST",
    "timeout": 0,
    "disableKeepAlive": false,
    // ...
  },
  "message": "read ECONNRESET"
}

Expected Resolution: I am seeking assistance in resolving the intermittent ECONNRESET error, which is impeding my ability to consistently send messages to the OpenAI deployment. I need help identifying the root cause of this issue and obtaining a solution.

Additional Information:
I am using Node.js v18.15.0.
The version of the @azure/openai library I am using is 1.0.0-beta.2.
Thank you for your support!

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 11 & macOS

Versions

1.0.0-beta.2

Mention any other details that might be useful


Thanks! We'll be in touch soon.

@ltara ltara changed the title Intermittent read ECONNRESET Error when Sending Messages to OpenAI Deployment Intermittent RestError: read ECONNRESET Error when Sending Messages to OpenAI Deployment Sep 30, 2023
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

1 participant