LoginSignup
0

More than 1 year has passed since last update.

[Node.js] Expressサーバーのタイムアウト時間を変更する

Last updated at Posted at 2022-05-19

2023/01/06追記
この記事のやり方だとレスポンスが返らないので、その対策をした記事を書きました

デフォルト

Expressでは、リクエストのタイムアウトデフォルト値が2分に設定されています。

タイムアウト時間を設定

以下のように、オプションとしてtimeoutが用意されています。そちらの値をミリ秒で指定することで、タイムアウト時間を変更することができます。

app.js
const express = require("express")
const app = express()
...
const appServer = app.listen(80, () => { })
appServer.timeout = 1000 * 60 * 5 // 5min

参考

※2022/5/19追記:見れなくなっちゃってますね
Node.js サーバーのタイムアウトの時間を変更する

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0