gpt4 book ai didi

javascript - 间歇性错误 "This socket has been ended by the other party"

转载 作者:太空宇宙 更新时间:2023-11-04 16:31:55 27 4
gpt4 key购买 nike

我正在连接到在 docker 容器上运行的 neo4j,当我尝试建立另一个连接/查询时,出现错误。错误是“此套接字已被对方结束”。这是我的 Dockerfile,其中包含打开的端口:

暴露7474 7473 7687

这是我的驱动程序实用程序:

var neo4j = require("neo4j-driver").v1,
config = require("../../config");

(function(module){
module.exports = function(){
config.neo4j.server = 'localhost';
return neo4j.driver("bolt://" + config.neo4j.server, neo4j.auth.basic(config.neo4j.user, config.neo4j.password));
}
}(module));

我向 Neo4j 查询的方式:

(function(module){
var driver = require('../../../utils/neo4j-driver')(),
Q = require('q'),
logger = require('../../../utils/logger'),
BaseNeo4jModel = require('../../../utils/neo4j-model');

function userDBAuth(user){
var deferred = Q.defer();
var session = driver.session();

session
//.run( "MATCH (a:Person) RETURN a.name AS name, a.uuid as uuid" )
.run("MATCH (user:User {email:{email}})"
+ "RETURN user",
{ email: user.email})
.then(function (result) {
logger.debug('fetching results...');

if(result.records.length > 0){
var records = [];

result.records.forEach(function(record){
records.push(new BaseNeo4jModel(record));
});

done();

deferred.resolve(records);
} else {
deferred.reject({sucess: false, message: 'User not Found'});
}

}).catch( function(err) {
logger.error(err);
done();
deferred.reject(err.fields[0]);
});

return deferred.promise;

function done(){
session.close();
driver.close();
}
}

module.exports = userDBAuth;

}(module));

这是我的堆栈跟踪:

{"name":"auth-services","hostname":"MacBook-Pro-de-Vinicius.local","pid":16292,"level":50,"err":{"message":"This socket has been ended by the other party","name":"Error","stack":"Error: This socket has been ended by the other party
at TLSSocket.writeAfterFIN [as write] (net.js:286:12)
at NodeChannel.write (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/neo4j-driver/lib/v1/internal/ch-node.js:285:20)
at Chunker.flush (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/neo4j-driver/lib/v1/internal/chunking.js:114:18)
at Connection.sync (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/neo4j-driver/lib/v1/internal/connector.js:487:21)
at Session.run (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/neo4j-driver/lib/v1/session.js:89:20)
at userDBAuth (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/app/api/auth/services/userDBAuth.js:13:7)
at Object._auth [as auth] (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/app/api/auth/services/auth.js:9:3)
at Server.auth (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/app/api/auth/resources/auth.js:7:12)
at next (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/restify/lib/server.js:906:30)
at f (/Users/viniciussouza/Sites/WeddSocial/backend/weddsocial-auth/node_modules/once/once.js:25:25)","code":"EPIPE"},"msg":"This socket has been ended by the other party","time":"2016-09-27T11:12:33.163Z","v":0}

我很绝望,请帮助我!

最佳答案

只是一个建议 - 但看起来您的成功路径并不总是调用 done() 方法,因此 session 并不总是关闭并返回到池中。

我建议您修改以下内容:

            if(result.records.length > 0){
var records = [];

result.records.forEach(function(record){
records.push(new BaseNeo4jModel(record));
});

done();

deferred.resolve(records);
} else {
deferred.reject({sucess: false, message: 'User not Found'});
}

要在 else block 中添加 done() 调用:

            if(result.records.length > 0){
var records = [];

result.records.forEach(function(record){
records.push(new BaseNeo4jModel(record));
});

done();

deferred.resolve(records);
} else {
done();
deferred.reject({sucess: false, message: 'User not Found'});
}

关于javascript - 间歇性错误 "This socket has been ended by the other party",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39723668/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com