• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Document Services API Node JS - Socket Hang up

Community Beginner ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Hi,

 

I've created a Node JS solution using the document services API which converts ~15 files to PDF, then combines them to a single PDF.

 

Almost every time i run it, one of the PDF conversion or combining operations fails with 'ServiceApiError: request timed out, 10 seconds expired' and 'Unexpected Error, request could not be completed Error: socket hang up'.

 

Due to how common this error is, the solution is currently unusable.

 

I saw another post on here mentioning a similar error and it was left that it was probably a connectivity issue. I do not beleive this is the case though. The Node JS app is running on a server in a corportate data centre and we do not have connection problems.

 

I also want to mention that the error is not occuring on a specific file conversion or combine. It changes each run. I've also tried to throttle it to reduce any potential connectivity issues by running all of the operations synchronously (1 by 1), rather than all at the same time. This didn't seem to make a difference.

 

Has anyone had experience with this or can suggest what I can do?

 

Thanks!

 

 

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , May 19, 2021 May 19, 2021

I believe this is now resolved and it turned out to be quite simple. I didn't realise you could configure the timeout lengths for the PDF Tools SDK as is in the documentation. When I increased from the default of 10 seconds it stopped the errors.

Votes

Translate

Translate
Community Expert ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Can you share the input files?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Sorry I can't. They contain sensitve information. They are all fairly standard Word, Excel, PowerPoint files I believe though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

 

// http: {
// 	connectTimeout:10000,
// 	readTimeout: 10000
// },

// change like this 

http: {
	connectTimeout: 20000,
	readTimeout: 20000
},

in node_modules/@adobe/pdfservices-node-sdk\src/internal/config/dc-services-default-config.js 41

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

I believe this is now resolved and it turned out to be quite simple. I didn't realise you could configure the timeout lengths for the PDF Tools SDK as is in the documentation. When I increased from the default of 10 seconds it stopped the errors.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

This can be done without having to change the source in node_modules while creating the ExecutionContext 

const httpConfig = {connectTimeout: 60000, readTimeout: 60000 /* 1 minute */};
const execContext = PDFServicesSdk.ExecutionContext.create(credentials, httpConfig);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2022 Oct 23, 2022

Copy link to clipboard

Copied

Passing in an httpConfig object did not work for me.  I had to update the node_module source. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2023 Dec 05, 2023

Copy link to clipboard

Copied

LATEST

With the NodeSDK, it seems that this config object must be built with a builder instance. Unfortunately this is undocumented but the following seemed to work for us. Hopefully, it helps or at the least, provides you some direction. Cheers.

 

 

      const credsBuilderInstance = PDFServicesSDK.Credentials as any;
      const configBuilderInstance = PDFServicesSDK.ClientConfig;

      const credentials = credsBuilderInstance
        .servicePrincipalCredentialsBuilder()
        .withClientId(clientId)
        .withClientSecret(clientSecret)
        .build();

      const clientConfig = configBuilderInstance
        .clientConfigBuilder()
        .withConnectTimeout(1000 * 10) // 10 seconds
        .withReadTimeout(1000 * 60) // 1 minute
        .withProcessingTimeout(1000 * 60 * 10) // 10 minutes
        .build();

      const executionContext = PDFServicesSDK.ExecutionContext.create(
        credentials,
        clientConfig,
      );​

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources