2014-12-14 3 views
2

받는 중 : RqlDriverError : 클러스터를 잠그는 데 너무 많은 핸드 쉐이크 타임 아웃 오류가 자주 발생합니다.RethinkDB : RqlDriverError : 핸드 쉐이크 타임 아웃 오류

오류 스택은 다음과 같습니다 요청이 시작될 때 그때 가까운 끝에 연결을 열

{ 
    "date": "Sun Dec 14 2014 07:59:14 GMT+0000 (Coordinated Universal Time)", 
    "process": { 
    "pid": 10664, 
    "uid": null, 
    "gid": null, 
    "cwd": "D:\\home\\site\\wwwroot", 
    "execPath": "D:\\Program Files (x86)\\nodejs\\0.10.32\\node.exe", 
    "version": "v0.10.32", 
    "argv": [ 
     "node.exe", 
     "D:\\home\\site\\wwwroot\\server.js" 
    ], 
    "memoryUsage": { 
     "rss": 31940608, 
     "heapTotal": 27892736, 
     "heapUsed": 14846880 
    } 
    }, 
    "os": { 
    "loadavg": [ 
     0, 
     0, 
     0 
    ] 
    }, 
    "trace": [ 
    { 
     "column": 13, 
     "file": "D:\\home\\site\\wwwroot\\node_modules\\rethinkdb\\errors.js", 
     "function": "new RqlDriverError", 
     "line": 14, 
     "method": null, 
     "native": false 
    }, 
    { 
     "column": 36, 
     "file": "D:\\home\\site\\wwwroot\\node_modules\\rethinkdb\\net.js", 
     "function": "null._onTimeout", 
     "line": 490, 
     "method": "_onTimeout", 
     "native": false 
    }, 
    { 
     "column": 15, 
     "file": "timers.js", 
     "function": "Timer.listOnTimeout [as ontimeout]", 
     "line": 112, 
     "method": "listOnTimeout [as ontimeout]", 
     "native": false 
    } 
    ], 
    "stack": [ 
    "RqlDriverError: Handshake timedout", 
    " at new RqlDriverError (D:\\home\\site\\wwwroot\\node_modules\\rethinkdb\\errors.js:14:13)", 
    " at null._onTimeout (D:\\home\\site\\wwwroot\\node_modules\\rethinkdb\\net.js:490:36)", 
    " at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)" 
    ], 
    "level": "error", 
    "message": "uncaughtException: Handshake timedout", 
    "timestamp": "2014-12-14T07:59:14.810Z" 
} 

. 임하여 연결을 엽니 다 사용 :

function createConnection(req, res, next) { 
    r.connect( 
     { 
      host: 'myhost', 
      db: 'mydb', 
      authKey: 'mykey' 
     }, function(err, conn) { 
     if (err) { 
      throw err; 
     } 
     else { 
      // Save the connection in `req` 
      req.conn = conn; 
      _conn = req.conn; 
      // Pass the current request to the next middleware 
      next(); 
     } 
    }); 
} 
app.use(createConnection); 

및 루트는이 연결을 관리 할 수있는 가장 좋은 방법입니다

function closeConnection(req, res, next) { 
    if(req.conn){ 
     req.conn.close(); 
    } 
    next(); 
} 
app.use(closeConnection); 

처리 된 후 다음? 이 오류에 대한 자세한 내용을 추적하려면 어떻게합니까?를 참조하십시오.

답변

1

그냥 오류를 던지는 대신 오류로 next을 호출한다고 가정합니다. 또한 연결의 수신기를 바인딩하고 "오류"이벤트를 수신 대기해야합니다.

처리하고 싶지 않다면 연결 풀을 사용할 수 있습니다. 주변에 몇 개의 라이브러리가 있습니다. 자동 풀이있는 rethinkdbdash를 사용할 수도 있습니다 (연결을 얻거나 해제 할 필요가 없으므로 미들웨어가 필요하지 않습니다).

+0

답장 Michael에게 감사드립니다. 다음 (오류)에 대해 정말로 옳았습니다. 그러나 오류 만 전달합니다. 불행히도 근본적인 문제를 변경하는 것을 예방하지 않습니다. – Chev

관련 문제