Elastic not connecting

elasticsearch
Tags: #<Tag:0x00007f57f5f167e8>

#1

Hello,

I’m trying to connect R to an reporting server in our network by using the elastic package, but for some reason it won’t connect.
If I logon remotely to the server, and use R with elastic, I can do connect() and R can read/write to the elastic db.
When I’m on my desktop and try to connect by using: connect(es_base==“http://192.168.x.x”, es_port=“5601”)
I get:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k

When using port 9200 I get:
Error:
Failed to connect to http://vm-reporting.kela.be:9200
Remember to start Elasticsearch before connecting

How can I connect?

Regards


#2

Thanks for your question @Aceto81

What version of elastic are you using? es_base is deprecated and replaced by es_host

Does the error happen on the connect() call or on a later call to something else?

It’s not completely clear to me what’s happening. “Remotely” means you are on a VPN to your work? “Desktop” means what exactly?


#3

Hello @sckott,

I was using 0.6.0, now I did an upgrade to the newest R-project, and elastic 0.8 and the problem is solved.

The problem was on connect()
We are in domain with different PC’s and servers, desktop was referring to my PC, in the same domain as the server, I could ping directly with no problem, but connect() wasn’t possible.

But problem resolved, thanks for your advice!

Ace


#4

Glad it works now. Aiming to refactor how connections are done some time soon - okay to ping you to get feedback on the new interface?


#5

Hi Sckott,

Sure you can get feedback on the new interface, but be aware that by no means I’m an Elastic expert.

I was looking for an email adress to contact you directly, but couldn’t find it.

Ace


#6

Thanks. It’s scott@ropensci.org


#7

Whoops, I think I was a bit too optimistic.
Connect worked out, but when I do a search, I get the same error.
Situation so far:
I 'm in a client-server environment, and trying to connect from R on my laptop to the elastic server, all in the same domain.
code:
connect(es_host=“reportingsrv”, es_port = 5601)

res <- Search(“ES-sales”, q=‘status:“B” AND doctype:“order”’,
body = ‘{
"_source": ["_id", “posnr”,“order quantity”, “open order quantity”]
}’,
size=10000)

After running this code I get:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k
(right here) ------^

Best Regards


#8

hard to say what could be going on there. A few suggestions:

  • try turning on verbose errrors e.g., connect(errors = "complete")
  • use verbose curl request output, e.g…, library(httr); Search(config = verbose())

#9

I tried both suggestions, but still the error message is only:
Error: lexical error: invalid char in json text.
var hashRoute = '/app/k
(right here) ------^

Running the same Search directly on our reporting server gives no errors.


#10

Can you do the request on the command line with curl or similar tool? Curious if that works. The error invalid char in json text. sure seems like it’s not getting back JSON or not getting back valid JSON for some reason


#11

Hi Scott,

When performing:
curl "http://reportingserver:5601/_search"
I get: {“statusCode”:404, “Error”:“Not Found”}

curl "http://reportingserver:9200/_search"
Returns curl(7) failed to connet : timed out.

When doing the same on the server:
curl "http://reportingserver:9200/_search"
I get a lots of results as return.

For some reason, the server won’t return any results when queries from another client.


#12

hmm, it seems like something to do with your configuration/setup. Maybe you have to be on the server and not connecting from another computer/IP address? Or a certain user-agent string?


#13

I moved all the scripts right on the server, and everything worked fine.

Thanks for the support!


#14

great, glad it works now