dakrone / es-mode

An Emacs major mode for interacting with Elasticsearch
GNU General Public License v3.0
196 stars 34 forks source link

Will not connect to localhost, only 127.0.0.1 on OS X #9

Closed goofansu closed 10 years ago

goofansu commented 10 years ago

Test code:

#+BEGIN_SRC es :method POST :url localhost:9200/_search?pretty
{
  "query": {
    "match_all": {}
  }
}
#+END_SRC

Curl results from "http://localhost:9200/_search?pretty":

curl -XPOST http://localhost:9200/_search\?pretty -d '{
    "query": {
        "match_all": {}
    }
}'
{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 35,
    "successful" : 35,
    "failed" : 0
  },
  "hits" : {
    "total" : 1683,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "OMZdDrpPSb-R3XauOGwJew",
      "_score" : 1.0, "_source" : {"message":"[info] <0.7.0> Application server started on node 'server@127.0.0.1'","@version":"1","@timestamp":"2014-04-01T02:35:30.000Z","type":"syslog","host":"127.0.0.1","priority":142,"timestamp":"Apr  1 10:35:30","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":6,"facility":17,"facility_label":"local1","severity_label":"Informational"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "qwAfiGrYQe2hD6gYS2xskA",
      "_score" : 1.0, "_source" : {"message":"[error] <0.388.0> CRASH REPORT Process <0.388.0> with 0 neighbours exited with reason: {unexpected_message,{inet_async,#Port<0.6145>,126,{error,closed}}} in yg_server_reader:do_lost/5 line 318","@version":"1","@timestamp":"2014-04-01T02:36:17.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:36:17","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "h4GHuSkSRF2f6p3csmSg0g",
      "_score" : 1.0, "_source" : {"message":"[info] <0.1022.0> I(<0.1022.0>:d:29) : reload holiday finished","@version":"1","@timestamp":"2014-04-01T02:38:02.000Z","type":"syslog","host":"127.0.0.1","priority":142,"timestamp":"Apr  1 10:38:02","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":6,"facility":17,"facility_label":"local1","severity_label":"Informational"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "N-3YBPirQESdS1JfuYtVlg",
      "_score" : 1.0, "_source" : {"message":"[error] <0.771.0> CRASH REPORT Process <0.771.0> with 0 neighbours exited with reason: {unexpected_message,{inet_async,#Port<0.7413>,56,{error,closed}}} in yg_server_reader:do_lost_child/5 line 302","@version":"1","@timestamp":"2014-04-01T02:54:16.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:54:16","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"38543","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "E900P-uKTbaqedca6HUKog",
      "_score" : 1.0, "_source" : {"message":"[info] <0.1189.0> I(<0.1189.0>:d:29) : reloading holidays","@version":"1","@timestamp":"2014-04-01T02:56:28.000Z","type":"syslog","host":"127.0.0.1","priority":142,"timestamp":"Apr  1 10:56:28","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"38543","severity":6,"facility":17,"facility_label":"local1","severity_label":"Informational"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "DvM8jXEuR8yuSMKh2Pq5lA",
      "_score" : 1.0, "_source" : {"message":"[info] <0.1189.0> I(<0.1189.0>:d:29) : reload holiday finished","@version":"1","@timestamp":"2014-04-01T03:01:28.000Z","type":"syslog","host":"127.0.0.1","priority":142,"timestamp":"Apr  1 11:01:28","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"38543","severity":6,"facility":17,"facility_label":"local1","severity_label":"Informational"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "QjkH9haJRjK-EWbkn7RPCw",
      "_score" : 1.0, "_source" : {"message":"[error] <0.321.0> Supervisor yg_tcp_client_sup had child yg_server_reader started with {yg_server_reader,start_link,undefined} at <0.783.0> exit with reason {unexpected_message,{inet_async,#Port<0.7432>,130,{error,closed}}} in context child_terminated","@version":"1","@timestamp":"2014-04-01T02:36:17.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:36:17","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "zU1gSki4Sf2qPLLf_G-f3g",
      "_score" : 1.0, "_source" : {"message":"[error] <0.321.0> Supervisor yg_tcp_client_sup had child yg_server_reader started with {yg_server_reader,start_link,undefined} at <0.782.0> exit with reason {unexpected_message,{inet_async,#Port<0.7429>,128,{error,closed}}} in context child_terminated","@version":"1","@timestamp":"2014-04-01T02:36:17.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:36:17","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "EmJ8hEDXR_CwGsBIUn_JHA",
      "_score" : 1.0, "_source" : {"message":"[error] <0.321.0> Supervisor yg_tcp_client_sup had child yg_server_reader started with {yg_server_reader,start_link,undefined} at <0.388.0> exit with reason {unexpected_message,{inet_async,#Port<0.6145>,126,{error,closed}}} in context child_terminated","@version":"1","@timestamp":"2014-04-01T02:36:17.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:36:17","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"36845","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    }, {
      "_index" : "logstash-2014.04.01",
      "_type" : "syslog",
      "_id" : "juhJTBS2RhaUHfEptzEv6w",
      "_score" : 1.0, "_source" : {"message":"[error] <0.316.0> Supervisor yg_tcp_client_sup had child yg_server_reader started with {yg_server_reader,start_link,undefined} at <0.772.0> exit with reason {unexpected_message,{inet_async,#Port<0.7414>,63,{error,closed}}} in context child_terminated","@version":"1","@timestamp":"2014-04-01T02:54:16.000Z","type":"syslog","host":"127.0.0.1","priority":139,"timestamp":"Apr  1 10:54:16","logsource":"suyejuns-MacBook-Pro.local","program":"ascq","pid":"38543","severity":3,"facility":17,"facility_label":"local1","severity_label":"Error"}
    } ]
  }
}

Any advice to debug what is wrong? Thank you

ljos commented 10 years ago

Are you running the latest version? It seems to work perfectly fine on my machine. Or, I have to change to 127.0.0.1 instead of localhost, but I thought that was because I have done something stupid to my config and I haven't bothered to figure out how to turn it back.

You could try to add M-x edebug-defun to org-babel-execute:es and es-org-execute-request and trace the execution and see if it does something wrong on the way. To do that you need to open ob-elasticsearch (in the es-mode folder) and run M-x edebug-defun inside the defun statement each of the functions I mentioned. Then you call C-c C-c in the org-src-block and edebug will open a new window. To continue the execution you need to press n. This will step you through the execution of the functions and display the result of each execution in the minibuffer.

goofansu commented 10 years ago

I downloaded elasticsearch 1.1.1. It's ok with 127.0.0.1 but error with localhost.

Don't know why, but the problem was solved.

Thanks.

ljos commented 10 years ago

Are you running OS X?

goofansu commented 10 years ago

Yes


Kind Regards, goofansu

2014-04-27 0:52 GMT+08:00 Bjarte Johansen notifications@github.com:

Are you running OS X?

— Reply to this email directly or view it on GitHubhttps://github.com/dakrone/es-mode/issues/9#issuecomment-41473882 .

ljos commented 10 years ago

Ok, then it isn't just me as I assumed earlier. I will look into this. I edited the issue title to better reflect what the problem is. If you are not interested in getting updates on the issue I think you can remove yourself from the watch list.

goofansu commented 10 years ago

Ok, thank you for writing this mode.

Your methods to test elasticsearch impressed me a lot.

ljos commented 10 years ago

It seems to be that this is an emacs bug and not a problem with the way we use url-retrieve. It is already fixed, but not in the current stable.

It did however start working again on my machine. I don't know why. Below follows the minimal example if someone wants to try it. (It needs a http-server running on localhost:9200 of course.) I am closing this issue as there is not anything we can do here to fix this.

(let ((url-request-method "GET"))
  (url-retrieve "http://localhost:9200"
   (function
    (lambda (status)
      (view-buffer-other-window
       (current-buffer))))))