0

In Express.js, by making some HTTP GET requests, if the operation on the server takes more than 5 seconds, it sends an error: "ETIMEDOUT" (status 200).

How can I solve this?

I tried to use connect-timeout middleware:

var longTimeout = require('connect-timeout')({ time: 20000 })

but without result.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
WHITECOLOR
  • 24,996
  • 37
  • 121
  • 181
  • Do you want this in express middleware or as http.get request ? – user568109 Jan 12 '14 at 13:16
  • I want server to send the data even after 5000 ms passed, client side is awaiting. – WHITECOLOR Jan 12 '14 at 14:42
  • Express doesn't time out by itself. What exactly is the operation that takes more than 5 seconds, and are you sure it isn't the client that is timing out the request because it's taking too long? – robertklep Jan 12 '14 at 15:03
  • Are you using the middleware correctly ? See here http://stackoverflow.com/questions/14408573/need-to-reduce-the-timeout-period-for-a-route-in-expressjs – user568109 Jan 12 '14 at 15:08
  • @user568109 Yes I referenced to the same example. – WHITECOLOR Jan 13 '14 at 03:40
  • @robertklep yes I extended timeout on the client, and I said that the server responses with status 200 and data: {error: “ETIMEDOUT”} – WHITECOLOR Jan 13 '14 at 03:41
  • @WHITECOLOR and I'm saying that Express doesn't generate such errors by itself. You're not explaining what *the operation* is, so hard to debug this issue... – robertklep Jan 13 '14 at 07:32
  • @robertklep the operation is request and manipulations with MongoDB. Operation with DB completes in more then 5 sec. It completes successfully but response with error is sent before. – WHITECOLOR Jan 13 '14 at 15:37
  • @WHITECOLOR [here's a gist](https://gist.github.com/robertklep/42bc461cc15550b58d3d) showing that Express doesn't generate timeouts if an operation (in this case, `setTimeout`) takes more than 5 seconds. – robertklep Jan 13 '14 at 15:40

0 Answers0