Nodejs&Mysql错误:已将握手入队后无法将其入队

时间:2019-05-18 11:04:07

标签: mysql node.js

我有此代码:

var http = require('http'),
    url = require('url'),
    mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "GODROCKS",
  database: "mysite"
});


// require the ger objects
http.createServer(function (request, response) {
  var query = url.parse(request.url,true).query;

var g = require('../ger')

// Create an Event Store Manager (ESM) that stores events and provides functions to query them
var esm = new g.MemESM()

// Initialize GER with the esm
var ger = new g.GER(esm);

ger.initialize_namespace('movies')

.then( function() {

  con.connect(function(err) {
    if (err) throw err;
    con.query("SELECT * FROM recommend", function (err, result, fields) {
      if (err) throw err;
      return ger.events(result);
    });
  });



})
.then( function() {
  // What things might alice like?



 return results_ = ger.recommendations_for_person('movies', query.name, {actions: {likes: 1}});

})
.then(function(results_) {
  return  recommendations = results_.recommendations;
  //var results = results_[reccomendations.m ap(({ thing }) => thing)];
})
.then(function (recommendations) {

  var recclist=[];
  recommendations.forEach(function(element) {
   recclist.push(element.thing);
  });
    return recclist;


})

.then( function(recommendations) {
  response.end(JSON.stringify(recommendations,null,2));
  response.end("\nRecommendations For 'alice'");
})

})
.listen(8080);


console.log('mysite server running ok http://127.0.0.1:8080/');

它给了我这个错误:

  

如果(err)抛出err; ^错误:已经无法加入握手   排队握手。在Protocol._validateEnqueue   (c:\ xampp \ htdocs \ mysite \ node_modules \ mysql \ lib \ protocol \ Protocol.js:221:16)   在Protocol._enqueue   (c:\ xampp \ htdocs \ mysite \ node_modules \ mysql \ lib \ protocol \ Protocol.js:138:13)   在Protocol.handshake   (c:\ xampp \ htdocs \ mysite \ node_modules \ mysql \ lib \ protocol \ Protocol.js:51:23)   在Connection.connect   (c:\ xampp \ htdocs \ mysite \ node_modules \ mysql \ lib \ Connection.js:119:18)   在c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ examples \ recc_.js:30:7在   tryCatcher   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ util.js:24:31)   在Promise._settlePromiseFromHandler   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ promise.js:454:31)   在Promise._settlePromiseAt   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ promise.js:530:18)   在Promise._settlePromiseAtPostResolution   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ promise.js:224:10)   在Async._drainQueue   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ async.js:182:12)   在Async._drainQueues   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ async.js:187:10)   在Instant.Async.drainQueues   (c:\ xampp \ htdocs \ mysite \ node_modules \ ger \ node_modules \ bluebird \ js \ main \ async.js:15:14)   在tryOnImmediate(timers.js:676:5)的runCallback(timers.js:705:18)

     

在processImmediate(timers.js:658:5)

0 个答案:

没有答案