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.

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).

  • 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? 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);
    }
}
  • 2
    and your point is? – Gokhan Arik May 22 '16 at 21:38
0

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"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.