elastic: Problems on connect

@dashaus, I copied it over from #57:

Hi, I have the same problem here:

panic: main: conn db: no Elasticsearch node available

goroutine 1 [running]:
log.Panicf(0x84de50, 0x11, 0xc2080c7e90, 0x1, 0x1)
    /usr/local/go/src/log/log.go:314 +0xd0
main.init·1()
    /Users/emilio/go/src/monoculum/init.go:40 +0x348
main.init()
    /Users/emilio/go/src/monoculum/main.go:334 +0xa4

goroutine 526 [select]:
net/http.(*persistConn).roundTrip(0xc2088ad1e0, 0xc2086a9d50, 0x0, 0x0, 0x0)
20:30:13 app         |  /usr/local/go/src/net/http/transport.go:1082 +0x7ad
net/http.(*Transport).RoundTrip(0xc20806c000, 0xc2086f6000, 0xc20873ff50, 0x0, 0x0)
20:30:13 app         |  /usr/local/go/src/net/http/transport.go:235 +0x558
20:30:13 app         | net/http.send(0xc2086f6000, 0xed4f18, 0xc20806c000, 0x21, 0x0, 
20:30:13 app         | 0x0)
    /usr/local/go/src/net/http/client.go:219
20:30:13 app         |  +0x4fc
net/http.(*Client).send(0xc08b00, 0xc2086f6000, 0x21
20:30:13 app         | , 0x0, 0x0)
    /usr/local/go/src/net/http/client.go:142 +0x15b
20:30:13 app         | net/http.(*Client).doFollowingRedirects(0xc08b00, 0xc2086f6000, 0x97cd00, 0x0, 0x0, 0x0)
20:30:13 app         |  /usr/local/go/src/net/http/client.go:367 +0xb25
net/http.(*Client).Do(0xc08b00, 0xc2086f6000, 0xc20873fce0, 0x0, 
20:30:13 app         | 0x0)
    /usr/local/go/src/net/http/client.go
20:30:13 app         | :174 +0xa4
github.com/olivere/elastic.(*Client).sniffNode(0xc208659d10, 0xc208569920, 0x15
20:30:13 app         | , 0x0, 0x0, 0x0)
20:30:13 app         |  /Users/emilio/go/src/github.com/olivere/elastic/client.go:543
20:30:13 app         |  +0x16a
20:30:13 app         | 
github.com/olivere/elastic.func·014(0xc208569920, 0x15
20:30:13 app         | )
    /Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x47
20:30:13 app         | created by github.com/olivere/elastic.(*Client).sniff
    /Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x744

goroutine 525 [chan receive]:
20:30:13 app         | database/sql.(*DB).connectionOpener(0xc2086de960)
    /usr/local/go/src/database/sql/sql.go:589 +0x4c
created by database/sql.Open
    /usr/local/go/src/database/sql/sql.go:452 +0x31c

goroutine 529 [IO wait]:
20:30:13 app         | net.(*pollDesc).Wait(0xc2084fe370, 0x72, 0x0
20:30:13 app         | , 
20:30:13 app         | 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc2084fe370, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc2084fe310, 0xc208709000, 0x1000, 0x1000, 0x0, 0xed4d48, 0xc2086a9ec8)
    /usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc20896a800, 0xc208709000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/go/src/net/net.go:121 +0xdc
net/http.noteEOFReader.Read(0xef0410, 0xc20896a800, 0xc2088ad238, 0xc208709000, 0x1000, 0x1000, 0xeb7010, 0x0, 0x0)
    /usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc208569b40, 0xc208709000, 0x1000, 0x1000, 0xc207f6957f, 0x0, 0x0)
    <autogenerated>:125 +0xd4
bufio.(*Reader).fill(0xc2088f3c80)
    /usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).Peek(0xc2088f3c80, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/bufio/bufio.go:132 +0xf0
net/http.(*persistConn).readLoop(0xc2088ad1e0)
    /usr/local/go/src/net/http/transport.go:842 +0xa4
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 530 [select]:
net/http.(*persistConn).writeLoop(0xc2088ad1e0)
    /usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:661 +0xcbc

This occurs sometimes… not always…

curl -XGET 127.0.0.1:9200/_nodes/http?pretty=1
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "3l_Ing0oSfWu5U63US5kxg" : {
      "name" : "Rattler",
      "transport_address" : "inet[192.168.1.91/192.168.1.91:9300]",
      "host" : "Mac-Emilio",
      "ip" : "192.168.1.91",
      "version" : "1.3.4",
      "build" : "a70f3cc",
      "http_address" : "inet[/192.168.1.91:9200]",
      "http" : {
        "bound_address" : "inet[/0:0:0:0:0:0:0:0:9200]",
        "publish_address" : "inet[/192.168.1.91:9200]",
        "max_content_length_in_bytes" : 104857600
      }
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 41 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @bmelton. It’s always been a problem with IP addresses up until now, so I guess that it’s the same with you. No worries, we’ll get this to work for you as well 😃

If you don’t use any special configurations, elastic will use the default IP (127.0.0.1:9200) to sniff all nodes on the ES cluster. It does that by using the network info API, similar to the one you used in your connect.py. It parses the IP addresses of all nodes ("http_address" : "inet[/172.17.0.31:9200]",), periodically checks them for availability and adds new nodes as they come. The process is described in the Wiki. See also: Connection problems.

If you disable sniffing, you must set the IP addresses of all nodes manually by SetURL(...). Notice that elastic would not find new nodes in your cluster then.

So if you’ve got only one ES node in your cluster and it’s available at 192.168.99.100:9200, this is supposed to work:

client, err := elastic.NewClient(
    elastic.SetSniff(false),
    elastic.SetURL("http://192.168.99.100:9200"),
)

Cheers.