moleculer-web
moleculer-web copied to clipboard
After 5 minutes i received an error.
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
Please create a repro example
Please create a repro example
https://codesandbox.io/s/moleculer-api-routing-forked-cxfnr8?file=/services/api.service.js
@cheungchingli try use callOptions

"use strict";
import ApiGateway from "moleculer-web";
import Koa from "koa";
import bodyParser from "koa-bodyparser";
import cors from "@koa/cors";
export default (broker: any) => {
return broker.createService({
name: "test",
mixins: [ApiGateway],
settings: {
server: false,
port: 27566,
httpServerTimeout: 100 * 60 * 1000,
},
dependencies: [
// 'package'
],
methods: {},
async created() {
const app: any = (this.app = new Koa());
app.broker = app.context.broker = broker;
app.use(cors());
app.use(bodyParser());
},
async started() {
try {
let server = await this.app.listen(Number(this.settings?.port));
server.requestTimeout = 100 * 60 * 1000;
server.timeout = 100 * 60 * 1000;
// server.keepAliveTimeout = 5000;
console.info(`web server started on port ${this.settings?.port}`);
} catch (error) {
return this.broker.fatal(error);
}
},
async stopped() {
if (this.app.listening) {
this.app.close((err: any) => {
if (err) {
return console.error("web server close error!", err);
}
console.info("web server stopped!");
});
}
},
});
};
how to set in this code?plz
@cheungchingli This code is fundamentally different from codesandbox. Create repro code with this, plz.
plz wait a moment
@intech https://codesandbox.io/s/competent-cray-ct7zkl?file=/index.js
The http.server timeouts have changed in Node.js v18. The headersTimeout is set to 60000 milliseconds (60 seconds), and requestTimeout is set to 300000 milliseconds (5 minutes) by default. The headersTimeout is the time that is allowed for an HTTP request header to be parsed. The requestTimeout is the timeout used for an HTTP request.
Why this issue related to moleculer-web if you use Koa?