iisnode icon indicating copy to clipboard operation
iisnode copied to clipboard

How to make iisnode wait for listen

Open joshua-mcginnis opened this issue 10 years ago • 4 comments

We're having an issue where iisnode is taking requests after node has started but before our application is listening. Because of this, there's a small period of time where iis returns 500's because the app hasn't fully initialized.

Is there a way to resolve this?

joshua-mcginnis avatar Mar 19 '14 17:03 joshua-mcginnis

Try increasing the value of maxNamedPipeConnectionRetry and/or namedPipeConnectionRetryDelay.

When a first HTTP request arrives that targets a particular Node.js application, iisnode will lazily create a node.exe process for that application. While the process is initializing and before it actually starts listening, IIS/iisnode will queue up any subsequent HTTP requests that target it. The way iisnode knows the node.exe is ready to accept HTTP requests is by periodically probing whether the listener is responsive. This probing behavior is controlled by namedPipeConnectionRetryDelay and maxNamedPipeConnectionRetry. If iisnode is unable to establish communication with node.exe after maxNamedPipeConnectionRetry, it will respond to all queued up HTTP requests with HTTP 500. The default values for these two settings work in most situations, but may need to be modified when the initialization logic of a node.js application is particularly heavy (which is sometimes the case with Express apps that compile views on initialization), or on particularly loaded servers.

tjanczuk avatar Mar 19 '14 18:03 tjanczuk

If you control your server, you can also try to use application initialization to always keep the Node.js application running instead of relying on message-based activation.

tjanczuk avatar Mar 19 '14 18:03 tjanczuk

@tjanczuk is this also possible with IIS 7 ? I'm having the exact same issue but I'm running IIS 7 and would like to switch from message-base-activation.

Siafu avatar Dec 03 '15 15:12 Siafu

I have same problem too, there is any solution yet ? Thanks

gustafyulianto avatar May 22 '21 06:05 gustafyulianto