Skip to content

Getting timeout issue #2078

Open
Open
@depatla

Description

@depatla

Issue: datadog-api-client Failing with ETIMEDOUT, Direct API Calls Work

Description
I am facing an issue where API requests made using datadog-api-client fail with a timeout error (ETIMEDOUT) only on my deployed server. However, when I make direct API calls using Axios (e.g., https://api.datadoghq.com/api/v1/dashboard), it works fine.

Error fetching cluster metrics: FetchError: request to https://api.datadoghq.com/api/v1/query?from=1740660092&to=1740660152&query=sum%3Akubernetes.cpu.requests%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Akubernetes.cpu.limits%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Akubernetes.cpu.usage.total%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Akubernetes.memory.requests%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Akubernetes.memory.limits%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Akubernetes.memory.usage%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Asystem.cpu.num_cores%7B*%7D+by+%7Bcluster_name%7D%2C+avg%3Asystem.cpu.idle%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Asystem.mem.total%7B*%7D+by+%7Bcluster_name%7D%2C+sum%3Asystem.mem.free%7B*%7D+by+%7Bcluster_name%7D failed, reason: connect ETIMEDOUT 3.233.153.176:443
at ClientRequest. (/home/monitoring/app/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (events.js:400:28)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT'
}

Observations
The issue only happens with datadog-api-client.
Direct API calls using Axios work fine.
Works locally, but fails when deployed.
Seems to be a connection issue (ETIMEDOUT), but only with the client library.
Expected Behavior
Requests using datadog-api-client should work in both local and deployed environments, just like direct API calls.

Steps to Reproduce
Deploy the application to a server.
Attempt to fetch cluster metrics using datadog-api-client.
Observe the timeout error.
Try the same request using Axios → Works fine.
Possible Causes
Proxy or network configuration: The client library might be using a proxy or network setting that causes issues on the server.
TLS or library-specific networking issues.
Different default timeouts or retry mechanisms in datadog-api-client vs. Axios.
Node.js version mismatch: The deployed environment may have a different version of Node.js affecting the behavior.
Workaround (Works with Axios)
const axios = require('axios');

axios.get('https://api.datadoghq.com/api/v1/dashboard', {
headers: {
'DD-API-KEY': 'xxx',
'DD-APPLICATION-KEY': 'xxx'
}
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
This works fine, but datadog-api-client still fails.

Request for Help
Are there any known issues with datadog-api-client in a deployed environment?
Is there a recommended way to debug or configure the client for better connectivity?
Any guidance would be greatly appreciated. Thanks! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions