-
Notifications
You must be signed in to change notification settings - Fork 131
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
Bulk request fails with "Data must be a string or a buffer" #44
Comments
@fiskeben thanks for the report. Any chance you can jump into the connector at runtime of your script and see what type I suspect it could be coming through there as something we don't expect. I have tried to reproduce in a test but haven't yet found a payload that can break What version of elasticsearch-js do you have? |
Thanks for the quick reply. I added some logging just before the
I'm using elasticsearch-js-13.3.1. |
Ah this is great, thanks. So the body is going missing somehow before retry. While we should try to fix that up, this does seem to be triggered by an issue connecting to your ES host. Can you try it with an https endpoint URL? Looks like there the host is attempting connection over http / |
Using However, I finally managed to figure it out. I added some more logging and it turned out the error came from signing the request. More debugging showed that the region was undefined which led me to how I create the client. Turns out I used the wrong name for the Thanks for the help. I don't know if the retry thing is an actual issue or a side effect of my little stunt here. You're welcome to close the issue if you will. |
I've run into the same issue when using v2.x or 3.x.
This is the config we're passing to
|
Any clue on this? I'm seeing this error as well but I don't see it outside AWS. |
I used to have the same issue but specifying the region resolved it (as @fiskeben suggested). import AWS = require("aws-sdk");
AWS.config.region = "us-east-1"; |
@haoliangyu Does the region have to be the region of ES instance? |
@TheDeveloper with default configuration as mentioned in docs is not working |
@zachguo Not sure. I have not tried the others, but my EC2 instance's region. |
This worked for me: const client = elasticsearch.Client({
hosts: process.env.ELASTICSEARCH_HOSTS,
connectionClass: require('http-aws-es'),
amazonES: {
accessKey: process.env.S3_ACCESS_KEY_ID,
secretKey: process.env.S3_SECRET_ACCESS_KEY
},
awsConfig: new AWS.Config({region: process.env.ELASTICSEARCH_REGION})
}); |
After digging into aws-sdk code, I found that:
const client = elasticsearch.Client({
hosts: ['host'],
connectionClass: require('http-aws-es'),
awsConfig: new AWS.Config({
accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2'
})
}); or AWS.config.update({
credentials: new AWS.Credentials('AKID', 'SECRET',
region: 'us-west-2'
});
const client = new elasticsearch.Client({
hosts: ['host'],
connectionClass: require('http-aws-es'),
awsConfig: AWS.config
}); |
THIS FINALLY WORKED FOR ME, THANKS SO MUCH! |
Hi,
I'm trying to use the
/_bulk
operation with ES 5.3 but I keep getting the error "Data must be a string or a buffer". I create my client the exact same way as the example in elastic/elasticsearch-es#274.The error message doesn't give a lot but here it is:
Using trace logging I can see that my body is there and it gets logged in the error handler callback in elasticsearch-js.
I've tried to serialize the body myself before passing it to the
bulk
function but I get the same error. I don't pass any other parameters.I haven't been able to trace down where the error actually occurs but I suspect it's in
this.httpClient.handleRequest
.My code works fine without the
AwsEsConnector
(using a local Elasticsearch).I'm beginning to suspect this could be a bug in the connector?
The text was updated successfully, but these errors were encountered: