This repository was archived by the owner on Sep 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Socket hang up while calling API from NodeJS #77
Copy link
Copy link
Open
Description
I'm calling weasyprint-rest container from NodeJS application. But sometimes API call breaks with error Socket Hang up.
Here is Full error message,
Error: socket hang up
at connResetException (node:internal/errors70414)
at Socket.socketOnEnd (node_http_client505:23)
at Socket.emit (nodeevents525:35)
at Socket.emit (nodedomain489:12)
at endReadableNT (node:internal/streams/readable135812)
at processTicksAndRejections (node:internal/process/task_queues8321)
[Sep-29-2022 094346] [error]: Error: Error: socket hang up
Here is the code I'm using to call weasyprint-rest container,
const axios = require('axios')
const FormData = require('form-data')
const data = new FormData();
const html = `<html>....</html>`;
const images = [ "logo.png", "sign.svg"]
data.append("html", html);
images.forEach( image => data.append('asset[]', fs.createReadStream(path.join(baseDir, `/public/templates/images/${image}`))))
const configConvert = {
url: process.env.WEASYPRINT_URL,
headers: { ...data.getHeaders(), 'Connection': 'keep-alive' },
responseType: "arraybuffer",
method: "POST",
data: data
};
const pdfResult = await axios(configConvert);
const base64data = new Buffer.from(pdfResult?.data, 'binary');
Any thought on how to fix it? Or any example to call it with library other than axios? Thank you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels