# API https://api.pdfjs.express/xfdf/extract takes too long to respond and returns an error

**URL:** <https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902>\
**Category:** Bug Reports\
**Created:** [July 25, 2022, 12:46pm UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902 "2022-07-25T12:46:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.curatitoli](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/m.curatitoli/32/882_2.png) [@m.curatitoli](https://pdfjs.community/u/m.curatitoli)\
**Post date:** [July 25, 2022, 12:46pm UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/1 "2022-07-25T12:46:47Z")

</div>

**Which product are you using?**  
PDF.js Express Plus

**PDF.js Express Version**  
8.7.0

**Detailed description of issue**  
I am using pdf.js express plus with angular.  
It very often happens (around 80-90% of the time) that the API [https://api.pdfjs.express/xfdf/extract](https://api.pdfjs.express/xfdf/extract) takes too long to respond and returns an error:

Since I always worked on only one document and since it has never been edited, I assumed that the problem was coming from the API, especially because occasionally it works.

**Expected behaviour**  
The request should return a valid response or at least include a more descriptive error text.

**Does your issue happen with every document, or just one?**  
As previously stated, I only worked with a document, that is the demo.pdf from the angular project sample.

**Link to document**

> <https://github.com/pdfjs-express/pdfjs-express-angular-sample/blob/master/src/files/webviewer-demo-annotated.pdf>

**Code snippet**

The code I used for calling the endpoint is the same as the one on the tutorial page.

The only difference is that the file does not come from a path, but from a blob file:

 ![documentLoad_2](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/9898821fa4b436f4a7d49df9c6ecce11f4355866.png)

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [July 25, 2022, 7:29pm UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/3 "2022-07-25T19:29:24Z")

</div>

Hi m.curatitoli,

I followed the angular sample repository [GitHub - pdfjs-express/pdfjs-express-angular-sample](https://github.com/pdfjs-express/pdfjs-express-angular-sample) and setup the extract API [Extract XFDF using the Express REST API | Documentation](https://pdfjs.express/documentation/utils/extract)  
and I was able to get the annotations loaded in the console:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/dc6f86c166d9a9d3c088439603ea44799a5c6685.jpeg)

I will need additional details to further troubleshoot:

1. Are you able to reproduce the error if you use the API without the utils (similar to above screenshot)
2. Do you have server/client keys setup? [PDF.js Express Utils Home](https://pdfjs.express/api/utils/)
3. Are you able to reproduce this error if the file was loaded from a path rather than a blob file?
4. Are you able to find out which error code the API returns: [PDF.js Express API Errors | Documentation](https://pdfjs.express/documentation/utils/errors)

Best Regards,

Kevin Kim  
Web Development Support Engineer  
PDFTron Systems, Inc.

---

<div class="post-metadata">

**Author:** ![m.curatitoli](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/m.curatitoli/32/882_2.png) [@m.curatitoli](https://pdfjs.community/u/m.curatitoli)\
**Post date:** [July 26, 2022, 8:15am UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/4 "2022-07-26T08:15:06Z")

</div>

Hi kkim,

Thank you for your quick response.  
Since I cannot upload more than one media file at a time, I will answer in 3 steps.

1. I used the API without utils but the same error is returned  

2. Yes, I generated the keys and added them correctly.

---

<div class="post-metadata">

**Author:** ![m.curatitoli](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/m.curatitoli/32/882_2.png) [@m.curatitoli](https://pdfjs.community/u/m.curatitoli)\
**Post date:** [July 26, 2022, 8:15am UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/5 "2022-07-26T08:15:58Z")

</div>

1. I tried to create the file and open it from a local path, but it gives me another error ({“error”:{“code”:21,“message”:“Cannot retrieve file from URL.”}}), even though the file gets initially loaded in the document:  
 ![extract_error_file](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/02230c377228e53ca591f03d6d3ae31b5d63ee42.jpeg)

Some other useful information:

1. I am working in a local environment (localhost).
2. The file I generated for the question 3. is served by the back-end that runs in localhost.

---

<div class="post-metadata">

**Author:** ![m.curatitoli](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/m.curatitoli/32/882_2.png) [@m.curatitoli](https://pdfjs.community/u/m.curatitoli)\
**Post date:** [July 26, 2022, 8:16am UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/6 "2022-07-26T08:16:47Z")

</div>

1. The problem is that the API does not return any error:  
 ![extract_error_2](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/d60c0222778298fc92e40e8932aefa0d632c64b8.jpeg)

Thank you for the support,  
I hope to have provided enough information.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [July 26, 2022, 4:36pm UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/8 "2022-07-26T16:36:27Z")

</div>

Hi there,

I tried reproducing your issue with the code you provided and unfortunately cannot reproduce either. Here is the code I used:

```javascript
instance.Core.documentViewer.addEventListener('documentLoaded', async () => {
     const fileData = await documentViewer.getDocument().getFileData({});
     const blob = new Blob([fileData], {type: 'application/pdf'})

     const data = new FormData();
     data.append("file", blob);

     const response = await fetch("https://api.pdfjs.express/xfdf/extract", {
        method: "post",
        body: data,
     }).then((resp) => resp.json());

    const { xfdf } = response;
    instance.Core.annotationManager.importAnnotations(xfdf)
})

```

The error you are seeing is “ERR\_CONNECTION\_RESET” which indicates this is an issue on your end, most likely with your network. Are you using a VPN, proxy for firewall that might be interfering with requests? Do you have any chrome extensions that might be blocking requests?

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![m.curatitoli](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/m.curatitoli/32/882_2.png) [@m.curatitoli](https://pdfjs.community/u/m.curatitoli)\
**Post date:** [July 27, 2022, 9:49am UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/9 "2022-07-27T09:49:15Z")

</div>

Hello Logan,

I tried to switch the network to the personal hotspot and the export worked.  
The problem was most likely due to our firm’s firewall.  
Can I ask you which port is used by your server, in order to enable it by configuration?

Thank you very much for the debugging,  
Mattia

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [July 27, 2022, 2:46pm UTC](https://pdfjs.community/t/api-https-api-pdfjs-express-xfdf-extract-takes-too-long-to-respond-and-returns-an-error/1902/10 "2022-07-27T14:46:28Z")

</div>

Hi Mattia,

You can use Port 443 (HTTPS) to connect.

Best Regards,

Kevin Kim  
Web Development Support Engineer  
PDFTron Systems, Inc.
