Samuel Thompson
Samuel Thompson

Reputation: 2576

Express timeout always occurs after 1 minute

I have an express server that hits a 1 minute timeout after publishing it to Cloud Foundry. Locally I can set any timeout that I want. It is probably a problem with Pivotal Cloud Foundry, but I am not sure what setting could be breaking things. Here is what I have tried in code:

https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_settimeout_msecs_callback

https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_timeout

https://github.com/expressjs/timeout

https://github.com/expressjs/express/issues/2174

Then just for kicks I put all of them into my code, and It still timed out after 1 minute. This is the raw response I get:

HTTP/1.1 504 GATEWAY_TIMEOUT
Content-Length: 0
Connection: keep-alive

I think there is some linux server configuration that maybe I have to set. Is there anything on node that would hard limit how long a connection can last? What would make it send that response? There is nothing in my code that would send a 504 GATEWAY_TIMEOUT. Locally when I set a 1 minute time out I don't even get that response. I get:

Empty reply from server

That is normal. Any suggestions are appreciated.

--------------------UPDATE--------------------

The GoRouter that Francisco Mateo spoke of is indeed the issue, but according to Pivotal support:

To change the timeout on the go router, you would have to modify the BOSH manifest of the go router. In a full Pivotal Cloud Foundry environment, this is a trivial change. However, we do not allow such changes to be made on Pivotal Web Services since they would affect more than a single customer.

It is apparently impossible to over ride it, but I can keep the connection alive if I send data every now and then. So if I send an empty space every 10 seconds then I can keep the connection alive forever. That is ugly though. The response will have a bunch of empty spaces and then the data will be shown.

Next question:

Is there any way to send a ping with no data?

I have tried sending an empty string but the Go Router sees that as sending nothing. Maybe an empty character?

Upvotes: 1

Views: 1600

Answers (1)

Cisco
Cisco

Reputation: 22952

This has nothing to do with Node or your Express application. This is due do the gorouter that Cloud Foundry uses which sets a timeout of 60 seconds.

See:

There may be a way to override it: https://docs.cloudfoundry.org/services/route-services.html#timeouts

Upvotes: 1

Related Questions