help
help copied to clipboard
After 5 minutes i received an error.
Details
503 Service Unavailable
I sended a request,but i got this response.
httpServerTimeout
for settings moleculer-web
and requestTimeout
for moleculer
broker config/settings
iI've set it up, but it still fails
I thought the cause might be the nodejs's requestTimeout
.
https://github.com/nodejs/node/blob/main/lib/_http_server.js#L383
Node.js version
v18.3.0
Example code
https://codesandbox.io/s/competent-cray-ct7zkl?file=/index.js
Operating system
ubuntu 22.04 arm64
Scope
none
Module and version
Not applicable.
I would ideally debug the server. For example:
$ NODE_DEBUG=http node app.js
this would print additional debug messages for the http code flow in the app. You can follow this model to debug you backend to see where things are going wrong.
Hope this helps.
They changed the HTTP timeout behaviour - Node v16 vs v18: v16: https://github.com/nodejs/node/blob/v16.x/lib/_http_server.js v18: https://github.com/nodejs/node/blob/v18.x/lib/_http_server.js You are going to see in v18 this code:
const requestTimeout = options.requestTimeout;
if (requestTimeout !== undefined) {
validateInteger(requestTimeout, 'requestTimeout', 0);
this.requestTimeout = requestTimeout;
} else {
this.requestTimeout = 300_000; // 5 minutes
}
5 minutes hardcoded here.
To fix: option 1 is to set timeouts when setting up http server:
const server = this.setupHttpServer();
server.timeouts = 120000 //timeout in milliseconds or just add "0"
server.requestTimeout = 120000 //timeout in milisendocs
Option 2 is to set requestTimeout upon each request:
req.connection.setTimeout
They changed the HTTP timeout behaviour - Node v16 vs v18: v16: https://github.com/nodejs/node/blob/v16.x/lib/_http_server.js v18: https://github.com/nodejs/node/blob/v18.x/lib/_http_server.js You are going to see in v18 this code:
const requestTimeout = options.requestTimeout; if (requestTimeout !== undefined) { validateInteger(requestTimeout, 'requestTimeout', 0); this.requestTimeout = requestTimeout; } else { this.requestTimeout = 300_000; // 5 minutes }
5 minutes hardcoded here.
To fix: option 1 is to set timeouts when setting up http server:
const server = this.setupHttpServer(); server.timeouts = 120000 //timeout in milliseconds server.requestTimeout = 120000 //timeout in milisendocs
Option 2 is to set requestTimeout upon each request:
req.connection.setTimeout
Thank you for your reply, which helped me a lot
@ching2018 - is this issue resolved?
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
@gireeshpunathil I can confirm that the provided solution from @Tzvetelin88 is working. However, this was a breaking change, and I think that it should be mentioned somewhere.