fullscale / elastic.js

A JavaScript implementation of the elasticsearch Query DSL
http://docs.fullscale.co/elasticjs/
MIT License
654 stars 163 forks source link

Can't connect to Bonsai on Heroku #50

Closed katowulf closed 10 years ago

katowulf commented 10 years ago

Hi There! Hoping to get some expert eyes to help me work through this config issue.

I've successfully run elasic.js vs a local ElasticSearch server. No problems or hangups to speak of--wacky fun! However, when I try to connect to Bonsai on Heroku, I start to see a barrage of these errors:

failed to index user/bruce: Error: getaddrinfo EFAULT
failed to index user/chan: Error: getaddrinfo EFAULT
failed to index user/chuck: Error: getaddrinfo EFAULT

I'm fairly well convinced this has something to do with the URL structure, which contains auth creds and does not seem to have a port number. It looks very close to this:

https://d38xxxxkb:dfxxxxxxxua2@birch-999999.us-east-1.bonsai.io

I can CURL against that URL with great success:

> curl -X POST https://d38xxxxkb:dfxxxxxxxua2@birch-999999.us-east-1.bonsai.io
{"ok":true,"acknowledged":true}

Additionally, however I set up the port number in elastic.js, I get the exact same error:

var URL = 'https://d38xxxxkb:dfxxxxxxxua2@birch-999999.us-east-1.bonsai.io';
ejs.client = nc.NodeClient(URL,  9200);  // same error
ejs.client = nc.NodeClient(URL,  80);     // same error
ejs.client = nc.NodeClient(URL,  null);   // same error
ejs.client = nc.NodeClient(URL,  '');       // same error
ejs.client = nc.NodeClient(URL,  false); // same error
ejs.client = nc.NodeClient(URL,  'foo');  // same error

I see a similar error running this from the jQuery client (it removes the auth creds and reports a 404):

ejs.client = ejs.jQueryClient('https://d47xxxxx:dfxxxxxxxxxx2@birch-9999999999.us-east-1.bonsai.io');
ejs.Document('index', 'user', '1').source({
     user: 'mrweber',
     message: 'Elastic.js - a Javascript implementation of the ElasticSearch Query DSL and Core API'})
     .doIndex(function() {});

image

What horrible sin of noobness have I fallen victim to?

Cheers,

mattweber commented 10 years ago

With the release of the official javascript client we will be dropping support for the various clients and move to supporting only the core dsl on top of the official client. I suggest you use the official client and then use the version of elasticjs from the master branch which is designed to work with the official client.

If you want to use the old version of elastic.js, something like the following should work:

ejs.client = nc.NodeClient('birch-999999.us-east-1.bonsai.io', '443', 'https').option('auth', 'd47xxxxx:dfxxxxxxxxxx2');
katowulf commented 10 years ago

Sounds great @mattweber; thanks for the follow-up!