3

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.

Andrew Watt
  • 131
  • 3

3 Answers3

1

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"/>
Iiridayn
  • 294
  • 2
  • 12
  • 1
    This is the correct answer. Thank you for sharing! I ran into the same issue with my app working locally but not on Azure Web Apps, should have suspected IIS sooner. – Sam Mar 23 '20 at 17:25
0

I assume you're running IIS on your VM (and don't make use of Azure App Service).
This SO question gives some directions how to disable IIS response buffering (aka AspBufferingOn).

Basically you need to install ASP feature and the option will be displayed in IIS Manager (see details here).

sebbrochet
  • 91
  • 2
  • This is an App Service, so unfortunately I don't have that option. – Andrew Watt May 15 '16 at 20:51
  • Have you check [this page](https://support.microsoft.com/en-us/kb/925764)? `You can disable buffering on the Web server, at the application level, or at the page level. When you disable buffering, the Web server uses HTTP chunked-transfer encoding to send the response to the Web client.` Web server level on Azure App Service doesn't seem possible, at the application level you need to modify a metabase property and that's also not possible but you may have a chance with the page level (it gives a solution with ASP), how would that translate in Node? If it doesn't work I'd switch to a Web role. – sebbrochet May 16 '16 at 16:29
0
on('request', function(request, response) {
    var interval = setInterval(function() {
        response.write("some data\r\n");
    }, 1000);
    request.on('close', function() {
        clearInterval(interval);
    }
}
user83763
  • 1
  • 1