ropensci / elastic

R client for the Elasticsearch HTTP API
https://docs.ropensci.org/elastic
Other
245 stars 58 forks source link

connect: Unable to connect to Elasticsearch server using connect #263

Closed mayankgautam closed 4 years ago

mayankgautam commented 4 years ago

I'm trying out elastic package to connect to elasticsearch on my system.

But I'm not able to connect using elastic package.

Here is the code that I've used with error message:

I've started the elasticsearch and have checked that the default page was opening in browser properly.

elasticon <- connect(port = 9200) elasticon$info()

Error: Failed to connect to http://127.0.0.1:9200 Remember to start Elasticsearch before connecting

sckott commented 4 years ago

is Elasticsearch running on localhost/127.0.0.1 and port 9200?

mayankgautam commented 4 years ago

Yes, it is.

On Fri, 9 Aug, 2019, 9:53 PM Scott Chamberlain, notifications@github.com wrote:

is Elasticsearch running on localhost/127.0.0.1 and port 9200?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ropensci/elastic/issues/263?email_source=notifications&email_token=AAPDJRCTFU3Y7XU4W3K36KDQDWKZNA5CNFSM4IKRDTVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD37EMTI#issuecomment-519980621, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPDJRGSXXF42N7N76LUC2DQDWKZNANCNFSM4IKRDTVA .

sckott commented 4 years ago

Okay, so is there a proxy or some authentication you need to connect to the ES running?

mayankgautam commented 4 years ago

Yes, I'm trying to connect behind a proxy.

I've tried below methods to connect to the server: set_config(use_proxy(url='http://XXX.XX.XX.XXX', XXXX, 'username@comp.com', 'password')) set_proxy(proxy("'http://XXX.XX.XX.XXX:XXXX", user = "username@comp.com", pwd = "password"))

But still, I'm not able to connect.

sckott commented 4 years ago

set_proxy and proxy are the correct fxns to use as the underlying http library is crul, not httr. try this:

library(elastic)
library(crul)
set_proxy(proxy("'http://XXX.XX.XX.XXX:1234", user = "username@comp.com", pwd = "password"))
x = connect()
x$info(verbose=TRUE)

verbose=TRUE gives verbose curl output, and should give some useful info if the proxy configuration is not working