Iis – How to configure IIS on Azure to stream chunked data from a Node.js app

azurehttphttp-streamingiisnode.js

I have a Node.js app that uses Transfer-Encoding: Chunked to stream data over HTTP continuously until the client disconnects. When running a local instance of Node, it works fine, but when deployed to an Azure App Service (which runs Node apps through iisnode), client connections hang without ever receiving data.

Logging indicates that the Node app is processing requests and streaming data correctly, but for some reason that data is not reaching the client.

Here's a simplified example of the way I'm streaming data from Node:

var server = http.createServer();
server.on('request', function(request, response) {
    var interval = setInterval(function() {
        response.write("some data\r\n");
    }, 1000);
    request.on('close', function() {
        clearInterval(interval);
    });
});
server.listen(config.port);

In my iisnode.yml config file I have set flushResponse: true to prevent iisnode from buffering response chunks.

My guess is that IIS is trying to buffer the entire response before sending it, but I don't know how to disable this behavior.

Best Answer

I had the exact same problem. Set flushResponse to true in web.config - see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full listing of options.

So, you'd have the line in web.config:

<iisnode flushResponse="true"/>
Related Topic