Entity is too large problem



  • Hi, I'm using jsreport 1.4.0 on windows system. I hit an error of entity is too large. The data sent to jsreport is 29Mb, I read the article that by default the limit is 20 Mb. I googled a lot and found a configuration settings, so I added a settings as below to both "dev.config.json" and "prod.config.json"

        "express": {
            "inputRequestLimit": "50mb"
        }
    

    Now from the log, it throws:

    2018-09-14T00:21:40.593Z - error: Error during processing request: http://172.20.42.42:3000/api/report details: request aborted Error: request aborted
        at IncomingMessage.onAborted (C:\Websites\Reports\node_modules\jsreport\node_modules\jsreport-express\node_modules\body-parser\node_modules\raw-body\index.js:270:10)
        at emitNone (events.js:67:13)
        at IncomingMessage.emit (events.js:166:7)
        at abortIncoming (_http_server.js:284:11)
        at Socket.serverSocketCloseListener (_http_server.js:297:5)
        at emitOne (events.js:82:20)
        at Socket.emit (events.js:169:7)
        at TCP._onclose (net.js:486:12)
    

    We have commercial licence. Can anyone help me how do I increase the request limit? If I did correctly, how can I avoid the "request aborted" error. I know the latest version of jsreport is 2.2, but it seems a big job to upgrade. So try upgrade would be my last choice.

    Thanks in advance for any help.



  • Your configuration is correct.

    The "request aborted" should mean that the client sending data disconnected before the input data stream was fully parsed.
    Try to check your client code.



  • Hi Jan,
    Thanks for reply. My client codes work well before I put the settings. The report returns correct data if I select date range from 1 Jan 2018 to 1 Jun 2018. But throw an error of "entity is too large" error if I select date range from 1 Jan 2018 to 10 Aug 2018. So I added the settings, then it throws the above error. At my client side code (c#), I increased the timeout to 10 mins. Below is my client code to get the report:

            public HttpResponseMessage RenderReport(string format, ReportResult data)
            {
                var view = _report.ViewFormats.FirstOrDefault(o => o.FormatName.ToLower() == format.ToLower());
                if (view == null)
                {
                    view = _report.DefaultViewFormat;
                }
    
                var client = new WebClient2()
                {
                    Timeout = 600000
                };
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
    
                dynamic rptData = new ExpandoObject();
                rptData.template = new ExpandoObject();
                rptData.template.shortid = view.ViewName;
                if (!string.IsNullOrEmpty(view.ViewType))
                {
                    rptData.template.recipe = view.ViewType;
                    rptData.options = new Dictionary<string, string>()
                    {
                        { "Content-Disposition", $"attachment; filename={_report.ReportName}.{view.FormatName}" }
                    };
                }
                rptData.data = data;
                var obj = Newtonsoft.Json.JsonConvert.SerializeObject(rptData);
                byte[] result = client.UploadData(ProviderService.Config.ReportHost, System.Text.UTF8Encoding.UTF8.GetBytes(obj));
                var responseContentType = client.ResponseHeaders.GetValues("content-type").FirstOrDefault();
                if (responseContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetf")
                    responseContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                if (responseContentType == "text/html")
                {
                    response.Content = new StringContent(System.Text.UTF8Encoding.UTF8.GetString(result));
                } else
                {
                    response.Content = new ByteArrayContent(result);
                    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = $"{_report.ReportName}.{view.FormatName}"
                    };
                }
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(responseContentType);
                response.Content.Headers.ContentLength = result.Length;
                return response;
            }
    

    Could you please have a look?

    Thanks.
    Chunsheng Cai



  • Hm. I don't use WebClient2. So not sure what is the issue.
    You can try to make a request from a different lib if it helps.



  • Hi Jan,
    The WebClient2 is just a class that inherited from normal .net WebClient, it just exposes the timeout for adjustment. Nothing special. You can just consider it as a normal WebClient. Here is WebClient2 code:

        public class WebClient2 : WebClient
        {
            protected override WebRequest GetWebRequest(Uri address)
            {
                var request = base.GetWebRequest(address);
                request.Timeout = Timeout;
                return request;
            }
    
            public int Timeout { get; set; } = 300000;
        }
    


  • Hm. I don't know. We use HttpClient in jsreport c# sdk.
    Maybe you can ask in an c# forum why WebClient aborts the request.



  • Hi Jan,

    You're right. I changed it to use HttpClient, now it works.

    Thanks a lot.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.