Node Express sends a sliced response in Azure App Service

Viewed 69

I have an express application running inside Azure App Service. I came across this weird behavior where I see in the logs that a response of 39.1 MB is sent from the server. But the client only gets a chunk of the response.

As an example, if the server responds with the following,

[
  {
    id: 1,
    name: 'john doe',
    address: 'park street'
  },
  {
    id: 2,
    name: 'john simon',
    address: 'ranger avenue'
  },
]

On the client side, I'm receiving the following,

[
  {
    id: 1,
    name: 'john doe',
    address: 'park street'
  },
  {
    id: 2,
    name: 'john simon',
   

As you can see, the response is sliced in the middle and it does not include the following.

    address: 'ranger avenue'
  },
]

When I used cURL command to get the response I can see that it is waiting until my response is fully completed but it never does and I see this in the terminal.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 30 39.1M   30 12.0M    0     0  46706      0  0:14:39  0:04:29  0:10:10     0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

I am guessing in between the client and my express server, Azure App Service is meddling with my response data which I could not able to figure out.

Here is my web.config file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <webSocket enabled="false" />
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>

        <rule name="StaticContent">
          <action type="Rewrite" url="public{PATH_INFO}"/>
        </rule>

        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          </conditions>
          <action type="Rewrite" url="server.js"/>
        </rule>
      </rules>
    </rewrite>
    
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>

Any help is much appreciated. Thank you!

Edit:

This behavior is random and sometimes I get the full response in the client-side. And I noticed this usually happens for large responses. If it is let's say 1 MB, it won't happen (at least when I was testing).

0 Answers
Related