0
我正在尝试创建elasticsearch索引并收到超时错误。注释掉的代码工作正常,所以服务器正在运行并且可以ping通。这里是我的代码:尝试创建elasticsearch索引时出现超时
import * as elasticsearch from "elasticsearch";
export const elasticClient = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace',
requestTimeout: 30000
});
// elasticClient.ping({
// requestTimeout: 30000,
// }, function (error) {
// if (error) {
// console.error('elasticsearch cluster is down!');
// } else {
// console.log('All is well');
// }
// });
// elasticClient.cluster.health({},function(err:any,resp:any) {
// console.log("-- Client Health --",resp);
// });
elasticClient.indices.create({
index: 'grr'
},function(err,resp,status) {
if(err) {
console.log(err);
}
else {
console.log("create",resp);
}
});
以下是错误消息:
Elasticsearch INFO: 2017-06-17T02:36:12Z
Adding connection to http://localhost:9200/
Elasticsearch DEBUG: 2017-06-17T02:36:12Z
starting request {
"method": "PUT",
"path": "/grr",
"query": {}
}
{ Error: Request Timeout after 30000ms
at C:\Users\myname\myproject\node_modules\elasticsearch\src\lib\transport.js:342:15
at Timeout.<anonymous> (C:\Users\myname\myproject\node_modules\elasticsearch\src\lib\transport.js:371:7)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
status: 408,
displayName: 'RequestTimeout',
message: 'Request Timeout after 30000ms' }
Elasticsearch TRACE: 2017-06-17T02:36:42Z
-> PUT http://localhost:9200/grr
<- 0
我真的在发生的事情的损失。我正在使用elasticsearch.js库的版本13.1.0
编辑: 我也尝试使用curl语句(直接从官方网站获取并修改为在Windows命令提示符下工作)来创建索引和我有类似的问题,除非它不超时;它只是陷入无限循环。
是否手动发出创建索引工作的请求?什么版本的ES? – ryanlutgen
5.4.1。我如何手动发出请求?我对这一切都很陌生 – Mike