繁体   English   中英

Node.js Lambda Epipe错误

[英]nodejs lambda epipe error

我收到此错误,无法找到任何原因。

我已将此代码部署在Amazon AWS上 是由于代码的异步执行吗? Stackoverflow告诉我要添加更多详细信息,但我所能提供的只是更多。

以下是我的代码的快照。

    "Error: write EPIPE
     at Object.exports._errnoException (util.js:870:11)
     at exports._exceptionWithHostPort (util.js:893:20)
   at WriteWrap.afterWrite (net.js:763:14)"

    module.exports.register = function(client, body, s, rclient, redis, callback){
    console.log("inside registration module function");
    console.log(body);
    console.log("mobile no", body.mobile_no);

    client.connectAsync()
.then(()=>
 {


return client.queryAsync('select count(*) from users where mobile_no=$1',[body.mobile_no]);})
.then(res=>{

console.log("connection successful");

if(res.rows[0].count==0)
{
    return client.queryAsync('insert into users(mobile_no, email, city, uname, password) values ($1, $2, $3, $4, $5)', [body.mobile_no, body.email, body.city, body.uname, body.password])
    .then(()=>{
        return client.queryAsync('select uid from users where mobile_no=$1',[body.mobile_no]);
    })
    .then(res=>{
        var uid = JSON.stringify(res);
        uid = JSON.parse(uid).rows[0].uid;

        console.log("uid: ", uid);

        console.log(uid);
        console.log(s);
        rclient.set(s,uid,redis.print);

        const response = {

            statusCode:201,
            body: JSON.stringify({
                sid: s,
                message: 'user registered',
            }),
        };

        console.log('success');
        return Promise.promisify(response);

    })
     .then(res=>{
        callback(null, res);
    })

}
else
{
    console.log("It is already registered mobile no");

              const response = {

            statusCode:412,
            body: JSON.stringify({
                sid: '',
                message: 'error: mobile no already registered',
            }),
        };

        Promise.promisify(response);

   }
 })
     .then(res=>{
     callback(null, res);
      })
    .then(()=>{

    client.end();
    rclient.quit();

  })

  .catch(err=>{
   console.log(err.stack);
    console.log("error occured");
   })

}

已知该错误的节点版本为v4.3.2 ,请下载最新版本。 请使用LTS version(6.10.0)或最新版本7.7.3 ,不再维护该版本。 这些版本稳定并且可以正常工作。

暂无
暂无

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

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