【发布时间】:2015-06-26 04:36:41
【问题描述】:
我正在尝试在 Cloud9 工作区上的 NodeJS 中实现弹性搜索客户端,我只是想让它运行。我的应用程序在端口 5678 上运行,我的 MongoDB 在 27017 上运行。我尝试搜索其他答案,但我并没有真正找到任何特别有用的东西。这是我在尝试连接到 localhost:9200 时收到的错误消息。
Elasticsearch ERROR: 2015-06-26T04:24:19Z
Error: Request error, retrying -- connect ECONNREFUSED
at Log.error (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/log.js:213:60)
at checkRespForFailure (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/transport.js:192:18)
at HttpConnector.<anonymous> (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/connectors/http.js:153:7)
at ClientRequest.wrapper (/home/ubuntu/workspace/node_modules/elasticsearch/node_modules/lodash/index.js:3128:19)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1552:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
Elasticsearch TRACE: 2015-06-26T04:24:19Z
-> HEAD http://localhost:9200/
<- 0
Elasticsearch WARNING: 2015-06-26T04:24:19Z
Unable to revive connection: http://localhost:9200/
Elasticsearch WARNING: 2015-06-26T04:24:19Z
No living connections
Trace: elasticsearch cluster is down!
at Server (/home/ubuntu/workspace/app.js:32:13)
at respond (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/transport.js:251:9)
at sendReqWithConnection (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/transport.js:171:7)
at next (/home/ubuntu/workspace/node_modules/elasticsearch/src/lib/connection_pool.js:213:7)
at process._tickCallback (node.js:442:13)
。
我的弹性搜索客户端代码很简单
var client = new elasticsearch.Client({
hosts: 'localhost:9200',
log: 'trace'
});
client.ping({
// ping usually has a 3000ms timeout
requestTimeout: 30000,
// undocumented params are appended to the query string
hello: "elasticsearch!"
}, function (error) {
if (error) {
console.trace('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
如果我尝试连接到 localhost:5678,我没有收到错误拒绝,但弹性集群仍然关闭?任何建议都会有所帮助,谢谢:)
【问题讨论】:
-
你的 elasticsearch 正在运行吗?如果 ES 未运行或未在端口 9200 上运行,则会弹出此错误
-
您好,非常感谢您的回复!它似乎正在运行,但它无法建立正确的连接或其他我不知道的错误。这是我定期收到的,这是我假设的 ping 请求。 Elasticsearch 跟踪:2015-06-26T19:57:21Z -> HEAD localhost:9200
-
当我运行 npm start 添加连接到localhost:9200 Elasticsearch DEBUG: 2015-06-26T20:10:23Z 开始请求{方法:'HEAD',requestTimeout: 30000,castExists:true,路径:'/',查询:{ keepAlive:false,你好:'elasticsearch!' } }
标签: node.js elasticsearch