简体   繁体   中英

Potly on Nodejs - “socket hang up and read ECONNRESET”

I have some error when use Plotly on Nodejs, can you help me?

I write a demo to generate image from splotly api, every 20 seconds, server will create a chart image. Some images is good, but then throw err as image:

在此处输入图片说明

在此处输入图片说明

My code:

 setInterval(function() { plotly.getImage(figure, imgOpts, function(error, imageStream) { if (error) return console.log(error); var time = new Date(); console.log("1--" + new Date()); var fileStream = fs.createWriteStream(time + '.png'); console.log("2--" + new Date()); imageStream.pipe(fileStream); // setTimeout(function(){ // console.log("3--"+new Date()); // //createPdfkit(time); // },10000); // imageStream.on('end',function(){ // // }); }); }, 20000); 

" ECONNRESET " in general, means that the connection your making has closed.

I assume that this error is being logged after the plotly.getImage() ? In this case, you'll need to simply handle the error. if (error) //don't continue The reason for the error could be that the image you're trying to get is not there, if it's not handled accordingly by plotly. You may have better luck posting on plotly's github issues .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM