New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout Not Working! #770
Comments
Hello! Can you upload a full example? |
Hey @delvedor – |
You can have a client-side timeout, which means that after
Can you be a little bit more specific? |
Sure –
Using the |
What kind of problems are you encountering? |
I'm stress testing ES connection with an empty query:
I'm using
Every run, after 200/250K queries the driver start throwing |
Your query is not correct, and the 'use strict'
const http = require('http')
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
node: 'http://localhost:9200',
agent: { maxSockets: 256 }
})
http.createServer((req, res) => {
client.search({
body: {
size: 0,
query: { match: { test: { query: 'test' } } }
}
}, (e, r) => {
if (e) console.log(e)
res.end('ok')
})
}).listen(3000) Autocannon:
I'm getting consistent results with good performances. |
Sorry – client.search({
body: {
size: 0,
query: { match: { test: { query: 'test' } } }
}
} I've repeated my test with different config conditions I'm working on an in-dev microservices framework that use Restify. The catch (error) {
console.log("int:", iteration, error.message);
if (error instanceof errors.NoLivingConnectionsErrorr) process.exit(1);
} Thus: every time I got a Full Config (for my use case)// THE ONLY .ENV SETTED IS: ELASTICSEARCH_QUERY_TIMEOUT=200
const _config = {
node: `http://${host}:${port}`,
sniffOnStart:
process.env. ELASTICSEARCH SNIFF_ON_START === "true" ? true : false,
sniffInterval: isNil(process.env.ELASTICSEARCH_SNIFF_INTERVALL)
? 60000
: Number(process.env. ELASTICSEARCH_SNIFF_INTERVALL),
requestTimeout: isNil(process.env.ELASTICSEARCH)
? 30000
: Number(process.env. ELASTICSEARCH_QUERY_TIMEOUT)
}; I've got the following result using Solution [for now]Then (as suggested me) I get rid of the Sniff config + I'added your suggested // THE ONLY .ENV SETTED IS: ELASTICSEARCH_QUERY_TIMEOUT=200
const prefix = "ELASTICSEARCH";
const _config = {
node: `http://${host}:${port}`,
// sniffOnStart:
// process.env[`${prefix}_SNIFF_ON_START`] === "true" ? true : false,
// sniffInterval: isNil(process.env[`${prefix}_SNIFF_INTERVALL`])
// ? 60000
// : Number(process.env[`${prefix}_SNIFF_INTERVALL`]),
requestTimeout: isNil(process.env[`${prefix}_QUERY_TIMEOUT`])
? 30000
: Number(process.env[`${prefix}_QUERY_TIMEOUT`])
agent: { maxSockets: 256 }
}; And the world changed: the test is still going (no quit!), and I bet it will go forever with exceptional performances. Autocannon ResultsRunning 10s test @ http://localhost:9001/go-elastic/
50 connections
Stat 2.5% 50% 97.5% 99% Avg Stdev Max
Latency 6 ms 8 ms 12 ms 15 ms 8.49 ms 2.28 ms 40.69 ms
Stat 1% 2.5% 50% 97.5% Avg Stdev Min
Req/Sec 5343 5343 5499 5855 5566 157.05 5341
Bytes/Sec 956 kB 956 kB 984 kB 1.05 MB 996 kB 28 kB 956 kB
Req/Bytes counts sampled once per second.
56k requests in 10s, 9.96 MB read My Configuration for test
I believe sniff is one of the big issue in the alpha so far Post ScriptumVery rarely I got the following error in my catch clause: Not every error is an Error. |
Glad to hear this!
Sniffing is a powerful tool, but it's also a double edge sword.
To be able to debug this I would need more info, you should use a nested try catch and see in which situation this error happens. |
I did what you asked like this: const { Client, errors } = require("@elastic/elasticsearch");
...
/* try to do the query*/.catch (error) {
try {
console.log(
"ERROR",
typeof error,
error instanceof errors.NoLivingConnectionsErrorr,
error
);
} catch (error2) {
console.log("E1", error, "E2", error2);
process.exit(1);
}
} it prints out (summarised):
Right-hand means that class ElasticsearchClientError extends Error{}
class NoLivingConnectionsError extends ElasticsearchClientError{} Then I did: console.log(
typeof errors.NoLivingConnectionsErrorr,
errors.NoLivingConnectionsErrorr
); And I've got Thus the problem is that const { Client, errors } = require("@elastic/elasticsearch"); is undefined (at least in my implementation). If I print out {
ElasticsearchClientError: [Function: ElasticsearchClientError],
TimeoutError: [Function: TimeoutError],
ConnectionError: [Function: ConnectionError],
NoLivingConnectionsError: [Function: NoLivingConnectionsError],
SerializationError: [Function: SerializationError],
DeserializationError: [Function: DeserializationError],
ConfigurationError: [Function: ConfigurationError],
ResponseError: [Function: ResponseError]
} |
Can you provide a complete example to reproduce? 'use strict'
const { errors } = require('@elastic/elasticsearch')
const connErr = new errors.ConnectionError()
console.log(typeof connErr) // object
console.log(connErr instanceof errors.ConnectionError) // true
console.log(connErr instanceof errors.TimeoutError) // false
console.log(connErr instanceof errors.ElasticsearchClientError) // true |
We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours. Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy |
Hi –
I'm trying to set query timeout even from connection using
requestTimeout
or on per query basis usingtimeout
onclient.search()
params. But either way is not working: it always use the default time out30000ms
.Some examples [NOT WORKING: timeout alwais is 30000ms]:
On Connection
Per Request
The text was updated successfully, but these errors were encountered: