2017-03-18 1 views
0

이 오류가 발생했습니다. & 이유를 찾을 수 없습니다.nodejs 람다 epipe 오류

이 코드를 아마존 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"); 
    }) 

} 
+0

여기서 exaclty는 오류가 생성 되었습니까? – Remario

+0

닫힌 스트림으로 파이핑 할 때 발생하는 EPIPE 오류 – Remario

+0

이 노드 버전 <= 노드 v0.6.16 인 경우 – Remario

답변

0

노드 버전이 v4.3.2 인 경우 가장 최근의 것을 다운로드하십시오. LTS version(6.10.0) 또는 더 이상 유지 관리되지 않는 최신 릴리스 인 7.7.3을 사용하십시오. 이 버전은 안정적으로 작동해야합니다.

+0

amazon은 현재 nodejs version6 버전을 지원하지 않습니다. 그래서, 그 해결책이 될 수 없습니다 –

+0

최신 아마존 지금은 지원이야? – Remario