4

A data intensive intranet application uses the following angularjs post function. It calls a Web API service returning a large JSON object in a chunked stream. This works perfectly well for responses of 100Mb but fails when the response reaches about 250 Mb.

$scope.refresh = function (){
        usSpinnerService.spin("main-grid");
        $http.post('/api/Assets/GetLargeJSONResult', $scope.postPayload
            ).then(
                function successCallback(response) {
                    $scope.mainGridOptions.api.setRowData(response.data);
                    $scope.mainGridOptions.api.refreshView();
                    clearErrorMessage();
            },
            httpErrorCallback)
            .then(refreshGridTwo)
            .finally(function () {
                usSpinnerService.stop("main-grid");
            });
};

Putting a breakpoint on the line $scope.mainGridOptions.api.setRowData(response.data); shows that response.data is an empty string.

Everything else works fine. I've tried various different ways of returning the JSON response from the web server and so I doubt the problem is on the server end. I'm targeting the Chrome browser in Windows.

Relevant request headers:

  • Accept: application/json, text/plain, /
  • Accept-Encoding: gzip, deflate, br
  • Accept-Language: en-US,en;q=0.8
  • Connection: keep-alive

Relevant response headers

  • HTTP/1.1 200 OK
  • Cache-Control: no-cache
  • Transfer-Encoding: chunked
  • Content-Type: application/json
  • Expires: -1

I know one option would be to page the response into smaller chunks. However, I would prefer to keep the data intact as it's being analysed in a grid. I wondered if I'm missing something as I can successfully stream very large open office xml files (media type "application/octet-stream") to the browser from Web API without any issues.

10
  • 1
    Similar questions: stackoverflow.com/q/28710394/215552, stackoverflow.com/q/22103927/215552, stackoverflow.com/q/23181492/215552 Commented Mar 13, 2017 at 22:28
  • Have you put a breakpoint where it actually returns the value in web api to make sure its serializing correctly? I've hit a point where it returns but hits a serialization error. Commented Mar 14, 2017 at 1:51
  • Dylan, There are no serialization errors. It returns correctly for objects of the same type but around 100Mb. It's due to the size. The similar questions posted by Mike (thanks!) all point to consuming the stream one chunk at a time, but there doesn't seem to be a simple 'angular' way of doing it. Commented Mar 14, 2017 at 13:34
  • Possibly a limit set by the web server. Have you tried accessing the data using an external tool such as curl, wget, etc.? Commented Mar 14, 2017 at 21:55
  • Check the value set for maxAllowedContentLength in your web.config. You can also check this link: strathweb.com/2012/09/… Commented Mar 14, 2017 at 22:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.