2015-04-20 43 views
0

我在Nodejs上使用Plotly時出現了一些錯誤,你能幫助我嗎?在Nodejs上可憐 - 「套接字掛斷並讀ECONNRESET」

我寫一個演示從splotly api生成圖像,每20秒,服務器將創建一個圖表圖像。有些圖片是好的,但再扔犯錯的圖像:

enter image description here

enter image description here

我的代碼:

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);

回答

1

ECONNRESET」,在一般情況下,意味着你所建立的連接已經完成osed。

我認爲這個錯誤是在plotly.getImage()之後記錄的?在這種情況下,你需要簡單地處理錯誤。 if (error) //don't continue錯誤的原因可能是您嘗試獲取的圖像不在那裏,如果它沒有通過繪圖處理。你可能有更好的運氣張貼在情節的github issues