System Information
- Strapi Version: “^3.6.6”
- Operating System: Amazon Linux (deployed in ECS fargate). Dockerfile is using strapi/base
- Database: mysql
- Node Version: >=10.16.0 <=14.x.x
- NPM Version: ^6.0.0
- Yarn Version:
We are using strapi for our service but we keep encountering errors that are not replicable but often occur during low traffic. Any tips are appreciated. Thank you
Whole Flow Setup
- Frontend (FE)
- FE AWS ALB → Apache (=mod_rewrite + mod_proxy) → Nuxtjs (FE)
- Backend (BE) = Strapi
- Nuxt.js (FE) → BE AWS ALB → Strapi (BE)
Errors
- Triggering requests from FE to BE will often result in HTTP 502 (ECONNTIMEOUT/ETIMEDOUT)
- We only observe that it will only happen during early morning hours where-in the requests load is not that huge
- Experiencing the same problem mentioned in the following articles
- https://github.com/nodejs/node/issues/27363
- Dealing with Intermittent 502's between an AWS ALB and Express Web Server · Adam Crowder
- It seems the connection from BE AWS ALB → Strapi (BE) is terminated forcibly without the ALB acknowledging that BE already closed the connection causing 502 errors.
- Below is the sample error from our logs for
ECONNRESET
error.
Message: [2022-04-12T02:56:04.741] [ERROR] default - FetchError: request to https://URL_HERE failed, reason: read ECONNRESET
at ClientRequest.<anonymous> (/PATH_TO_FILE/index.js:1461: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: 'ECONNRESET',
code: 'ECONNRESET'
Solutions that were implemented but did not fixed the issue
- The same strapi’s
keepAliveTimeout
andheadersTimeout
value- strapi service’s load balancer idle timeout: 300 seconds
- strapi service’s
keepAliveTimeout
: 301 seconds - strapi service’s
headersTimeout
: 301 seconds
- The strapi’s
headersTimeout
greater thankeepAliveTimeout
- strapi service’s load balancer idle timeout: 300 seconds
- strapi service’s
keepAliveTimeout
: 301 seconds - strapi service’s
headersTimeout
: 302 seconds
- Disable both
headersTimeout
andkeepAliveTimeout
- strapi service’s load balancer idle timeout: 300 seconds
- strapi service’s
keepAliveTimeout
: 0 seconds - strapi service’s
headersTimeout
: 0 seconds