2

I have a Spring application running on Tomcat 8.5 that queries our database, generates a PDF file, and then serves it to the user via the ServletOutputStream:

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    //PDDocument from org.apache.pdfbox.pdmodel
    this.document.save(byteArrayOutputStream);
    int pdfDocumentSize = byteArrayOutputStream.size();

    response.setContentLength(pdfDocumentSize);

    ServletOutputStream resOutputStream = response.getOutputStream();

    byteArrayOutputStream.writeTo(resOutputStream);
    response.flushBuffer();

    byteArrayOutputStream.close();
    resOutputStream.close();
    this.document.close();

For the vast majority of users, this works fine. However, we have received reports that some users are having a lot of trouble downloading this file. They click on the download link, and the page sits for about 3 minutes before crashing (They get an ERR_EMPTY_RESPONSE message). Occasionally, the file opens properly after this wait period.

Unfortunately, we are personally unable to replicate this issue.

According to our logs, the file is generated correctly. The file size is relatively small (105631 bytes, or about .1MB), so I don't think it's due to size. The logs also seem to indicate that the file was created correctly.

The logs also show a

    org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe

Which would normally indicate that the user aborted the download. However, we watched the user replicate this issue via screencast, and no actions were taken that would abort it. This user was also on a MAC. We don't have any MACs to test on here, but we do have an iPad. The iPad was able to download the file successfully as well.

What could be causing this?

Update: We've heard from another user that they are also experiencing this problem. They are on a Windows operating system and using Chrome. Different browsers have been tried, but they all behave the same.

In addition, the exception being generated in the log is about 10 minutes later than the time the error was reported.

DFL
  • 173
  • 1
  • 14

0 Answers0