简体   繁体   English

表达发送不完整的响应json数据

[英]express send incomplete response json data

The version info: "express": "~4.15.2", "express-session": "^1.15.5", 版本信息:“ express”:“〜4.15.2”,“ express-session”:“ ^ 1.15.5”,

I use this code send large json data to client: 我使用此代码将大型json数据发送到客户端:

   router.get('/exportAllData',function(req,res,next){
    async function getData(){
    let sql="SELECT * FROM int_information "
    let rows=await query(sql);
    let data=await JSON.stringify(rows);
    return JSON.parse(data);
  }
  getData().then(data=>res.send({flag:1,data:data})).catch(error=>{
    res.send({flag:0,err:error});
  });  
})

I tried wget localhost on server and can get full data, But the remote client got broken json data and different each time refresh. 我在服务器上尝试了wget localhost并可以获取全部数据,但是远程客户端的json数据已损坏,每次刷新时都不同。 Where is the problem? 问题出在哪儿? Seems response closed before get all data. 在获取所有数据之前,似乎响应已关闭。

This is an open bug in node js 8.x, I use 7.10 solved this problem. 这是节点js 8.x中的一个开放错误,我使用7.10解决了此问题。 Or you can set server.keepAliveTimeout=30000 in app.js to extend timeout setting 或者,您可以在app.js中设置server.keepAliveTimeout = 30000来扩展超时设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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