-
Notifications
You must be signed in to change notification settings - Fork 68
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
Reconnection is not supported #72
Comments
@delvedor maybe you can help? Otherwise it would be good for you to send a PR. |
Is there any update about this feature? |
@alexandrevanhoutte |
We're experiencing the same issue, once the ES instance crashes or any network congestion hits the roof, the connection gets broken. While inspecting the
Maybe setting this one to |
Maybe? Would you like to send a PR? |
I can give it a try 😄 |
@penumbra23 it won't solve this specific issue out if the box, the the v8 client uses a new type of connection pool. Try to use ClusterConnectionPool in the client configuration, the ping is the default behavior. It would be useful to understand why the client can't reconnect. The connection pool will retry connection either way after a while. It might be something related to the underlying http library itself. |
I have a service which, on startup, sometimes logs the following from a pino-elasticsearch
It will then never try to reconnect again until I restart the service. Before that, I see that elasticsearch retries sending messages several times when setting the environment variable
After the pino-elasticsearch error, nothing from Does this help fixing the issue? |
Is there any plan for reconnection to be implemented as a feature? I'm doing some development that could benefit from it |
My hope is that somebody will eventually send a PR for this. I currently do not have time. |
The main problem in I can try fix it and make PR but before I want to be sure that it isn't in vain, because my implementation will do the same It'll help me if somebody has a ready solution and you can publish it in this thread. |
It was a little easier) |
trhx |
How can I set a resurrect strategy? Is there a way? |
Yes, have the same problem. If at the start of process the elasticsearch node is not available then you have no logs before process restart. |
Would you like to send a PR? |
@mcollina that client problem I can share my dirty hack like as a temporary solution which just ignore all connection errors import { UndiciConnection } from '@elastic/transport';
export class IgnoreErrorConnection extends UndiciConnection {
constructor(opts) {
super(opts);
this.requestAfter = null;
this.requestAfterInterval = 5 * 60000;
}
async request(params, options) {
const now = new Date();
if (this.requestAfter && this.requestAfter > now) {
return this.fakeResponse(params);
}
try {
const response = await super.request(params, options);
this.requestAfter = null;
return response;
} catch (err) {
switch (err.name) {
case 'TimeoutError':
case 'ConnectionError': {
this.requestAfter = new Date(now.valueOf() + this.requestAfterInterval);
return this.fakeResponse(params);
}
default: {
throw err;
}
}
}
}
fakeResponse(params) {
const docs = params.body.split('\n').length;
const result = {
errors: false,
took: docs,
items: Array(docs).fill({ result: 'created', status: 201 })
};
const body = JSON.stringify(result);
return {
statusCode: 200,
headers: {
'content-type': 'application/vnd.elasticsearch+json;compatible-with=8',
'content-length': body.length,
'x-elastic-product': 'Elasticsearch'
},
body
};
}
}
const elastic = pinoElastic({
...
Connection: IgnoreErrorConnection,
...
}); |
When connection with elasticsearch server is broken, it won't send any msg to server any more. Can you add this feature?
The text was updated successfully, but these errors were encountered: