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
}
}
}
}
@dashaus I ran a program over night in the hopes of finding your problem. It simple connected to ES (which starts the sniffing process), then waits a few milliseconds, rinse and repeat. I'm afraid, I didn't have a single error in over 1 mio. connection attempts.
I'm also using ES locally on 127.0.0.1:9200 when developing and I didn't have that error once. So either I'm really lucky or there's something different between the way you are using ES/Elastic and I'm using it. Well, I'm at 1.5.0 and you're at 1.3.4, but that shouldn't be a problem. Go is 1.4.2 here.
Do you create one client for your app, or are you creating clients on demand?
I create one client for my app. For me, it's stranger, not always occurs... but when i do a change in my app, the server restarts and is there when, sometimes, occurs this error...
I can't get it to fail, even after 2 days. Can you run this gist for a while? If it fails, can you return the stack trace. Thank you.
Ok. I ran by go run <name_gist_file> and within seconds, the following error is raised:
no Elasticsearch node available
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x9d701]
goroutine 1 [running]:
github.com/olivere/elastic.(*PingService).Do(0xc20803b1a0, 0x0, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/ping.go:102 +0x471
github.com/olivere/elastic.(*Client).ElasticsearchVersion(0x0, 0x405290, 0x15, 0x0, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:827 +0x9b
main.main()
/Users/emilio/Dropbox/test_es.go:28 +0x241
goroutine 5 [select]:
net/http.(*persistConn).roundTrip(0xc208086000, 0xc20800adb0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1082 +0x7ad
net/http.(*Transport).RoundTrip(0xc208038090, 0xc2080320d0, 0xc20803b020, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:235 +0x558
net/http.send(0xc2080320d0, 0x687df0, 0xc208038090, 0x21, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:219 +0x4fc
net/http.(*Client).send(0x5b7be0, 0xc2080320d0, 0x21, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:142 +0x15b
net/http.(*Client).doFollowingRedirects(0x5b7be0, 0xc2080320d0, 0x483620, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:367 +0xb25
net/http.(*Client).Do(0x5b7be0, 0xc2080320d0, 0xc20803afc0, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:174 +0xa4
github.com/olivere/elastic.(*Client).sniffNode(0xc208080000, 0xc20801e960, 0x15, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:543 +0x16a
github.com/olivere/elastic.func·014(0xc20801e960, 0x15)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x47
created by github.com/olivere/elastic.(*Client).sniff
/Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x744
goroutine 8 [IO wait]:
net.(*pollDesc).Wait(0xc208010df0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc208010df0, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc208010d90, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x687b48, 0xc20800ae28)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc208036080, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc
net/http.noteEOFReader.Read(0x688fb8, 0xc208036080, 0xc208086058, 0xc20800f000, 0x1000, 0x1000, 0x676010, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc20801ea80, 0xc20800f000, 0x1000, 0x1000, 0xc207ffc9f7, 0x0, 0x0)
<autogenerated>:125 +0xd4
bufio.(*Reader).fill(0xc20805a600)
/usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).Peek(0xc20805a600, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:132 +0xf0
net/http.(*persistConn).readLoop(0xc208086000)
/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 9 [select]:
net/http.(*persistConn).writeLoop(0xc208086000)
/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
exit status 2
Can you run with go run -race .go and send the output on failure, please?
Am 02.04.2015 um 20:13 schrieb dashaus [email protected]:
Ok. I ran by go run <name_gist_file> and within seconds, the following error is raised:
no Elasticsearch node available panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x9d701]
goroutine 1 [running]: github.com/olivere/elastic.(_PingService).Do(0xc20803b1a0, 0x0, 0x0, 0x0, 0x0) /Users/emilio/go/src/github.com/olivere/elastic/ping.go:102 +0x471 github.com/olivere/elastic.(_Client).ElasticsearchVersion(0x0, 0x405290, 0x15, 0x0, 0x0, 0x0, 0x0) /Users/emilio/go/src/github.com/olivere/elastic/client.go:827 +0x9b main.main() /Users/emilio/Dropbox/test_es.go:28 +0x241
goroutine 5 [select]: net/http.(_persistConn).roundTrip(0xc208086000, 0xc20800adb0, 0x0, 0x0, 0x0) /usr/local/go/src/net/http/transport.go:1082 +0x7ad net/http.(_Transport).RoundTrip(0xc208038090, 0xc2080320d0, 0xc20803b020, 0x0, 0x0) /usr/local/go/src/net/http/transport.go:235 +0x558 net/http.send(0xc2080320d0, 0x687df0, 0xc208038090, 0x21, 0x0, 0x0) /usr/local/go/src/net/http/client.go:219 +0x4fc net/http.(_Client).send(0x5b7be0, 0xc2080320d0, 0x21, 0x0, 0x0) /usr/local/go/src/net/http/client.go:142 +0x15b net/http.(_Client).doFollowingRedirects(0x5b7be0, 0xc2080320d0, 0x483620, 0x0, 0x0, 0x0) /usr/local/go/src/net/http/client.go:367 +0xb25 net/http.(_Client).Do(0x5b7be0, 0xc2080320d0, 0xc20803afc0, 0x0, 0x0) /usr/local/go/src/net/http/client.go:174 +0xa4 github.com/olivere/elastic.(_Client).sniffNode(0xc208080000, 0xc20801e960, 0x15, 0x0, 0x0, 0x0) /Users/emilio/go/src/github.com/olivere/elastic/client.go:543 +0x16a github.com/olivere/elastic.func·014(0xc20801e960, 0x15) /Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x47 created by github.com/olivere/elastic.(*Client).sniff /Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x744
goroutine 8 [IO wait]: net.(_pollDesc).Wait(0xc208010df0, 0x72, 0x0, 0x0) /usr/local/go/src/net/fd_poll_runtime.go:84 +0x47 net.(_pollDesc).WaitRead(0xc208010df0, 0x0, 0x0) /usr/local/go/src/net/fd_poll_runtime.go:89 +0x43 net.(_netFD).Read(0xc208010d90, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x687b48, 0xc20800ae28) /usr/local/go/src/net/fd_unix.go:242 +0x40f net.(_conn).Read(0xc208036080, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x0, 0x0) /usr/local/go/src/net/net.go:121 +0xdc net/http.noteEOFReader.Read(0x688fb8, 0xc208036080, 0xc208086058, 0xc20800f000, 0x1000, 0x1000, 0x676010, 0x0, 0x0) /usr/local/go/src/net/http/transport.go:1270 +0x6e net/http.(_noteEOFReader).Read(0xc20801ea80, 0xc20800f000, 0x1000, 0x1000, 0xc207ffc9f7, 0x0, 0x0)
:125 +0xd4 bufio.(_Reader).fill(0xc20805a600) /usr/local/go/src/bufio/bufio.go:97 +0x1ce bufio.(_Reader).Peek(0xc20805a600, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/go/src/bufio/bufio.go:132 +0xf0 net/http.(_persistConn).readLoop(0xc208086000) /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 9 [select]: net/http.(_persistConn).writeLoop(0xc208086000) /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 exit status 2 — Reply to this email directly or view it on GitHub.
no Elasticsearch node available
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0xc8da5]
goroutine 1 [running]:
github.com/olivere/elastic.(*PingService).Do(0xc20803acf0, 0x0, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/ping.go:102 +0x565
github.com/olivere/elastic.(*Client).ElasticsearchVersion(0x0, 0x524eb0, 0x15, 0x0, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:827 +0xcf
main.main()
/Users/emilio/Dropbox/test_es.go:28 +0x2c0
goroutine 3822 [select]:
net/http.(*persistConn).roundTrip(0xc208086000, 0xc20800aad0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1082 +0xa69
net/http.(*Transport).RoundTrip(0xc208030000, 0xc2080324e0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:235 +0x6b8
net/http.send(0xc2080324e0, 0x11bcd18, 0xc208030000, 0xc20803ac00, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:219 +0x6f3
net/http.(*Client).send(0x725000, 0xc2080324e0, 0x21, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:142 +0x201
net/http.(*Client).doFollowingRedirects(0x725000, 0xc2080324e0, 0x5c06c0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:367 +0xf18
net/http.(*Client).Do(0x725000, 0xc2080324e0, 0xc20803ab40, 0x0, 0x0)
/usr/local/go/src/net/http/client.go:174 +0xc4
github.com/olivere/elastic.(*Client).sniffNode(0xc2080d6000, 0xc2080f71c0, 0x15, 0x0, 0x0, 0x0)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:543 +0x19b
github.com/olivere/elastic.func·014(0xc2080f71c0, 0x15)
/Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x68
created by github.com/olivere/elastic.(*Client).sniff
/Users/emilio/go/src/github.com/olivere/elastic/client.go:508 +0x95f
goroutine 11 [IO wait]:
net.(*pollDesc).Wait(0xc208010370, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x63
net.(*pollDesc).WaitRead(0xc208010370, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x51
net.(*netFD).Read(0xc208010310, 0xc208089000, 0x1000, 0x1000, 0x0, 0x11bcb48, 0xc20800aea0)
/usr/local/go/src/net/fd_unix.go:242 +0x4b3
net.(*conn).Read(0xc208036068, 0xc208089000, 0x1000, 0x1000, 0x3a0e2, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0x125
net.(*TCPConn).Read(0xc208036068, 0xc208089000, 0x1000, 0x1000, 0x5c08d0, 0x0, 0x0)
<autogenerated>:36 +0x86
net/http.noteEOFReader.Read(0x11bdee0, 0xc208036068, 0xc208086108, 0xc208089000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1270 +0x7c
net/http.(*noteEOFReader).Read(0xc20801e840, 0xc208089000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
<autogenerated>:125 +0xfc
bufio.(*Reader).fill(0xc2080526c0)
/usr/local/go/src/bufio/bufio.go:97 +0x382
bufio.(*Reader).Peek(0xc2080526c0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:132 +0x199
net/http.(*persistConn).readLoop(0xc2080860b0)
/usr/local/go/src/net/http/transport.go:842 +0xff
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:660 +0x10d4
goroutine 8 [IO wait]:
net.(*pollDesc).Wait(0xc208010e60, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x63
net.(*pollDesc).WaitRead(0xc208010e60, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x51
net.(*netFD).Read(0xc208010e00, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x11bcb48, 0xc20800b160)
/usr/local/go/src/net/fd_unix.go:242 +0x4b3
net.(*conn).Read(0xc208036090, 0xc20800f000, 0x1000, 0x1000, 0xc208010f38, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0x125
net.(*TCPConn).Read(0xc208036090, 0xc20800f000, 0x1000, 0x1000, 0xc20807bf40, 0x0, 0x0)
<autogenerated>:36 +0x86
net/http.noteEOFReader.Read(0x11bdee0, 0xc208036090, 0xc208086058, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1270 +0x7c
net/http.(*noteEOFReader).Read(0xc20801eac0, 0xc20800f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
<autogenerated>:125 +0xfc
bufio.(*Reader).fill(0xc208052660)
/usr/local/go/src/bufio/bufio.go:97 +0x382
bufio.(*Reader).Peek(0xc208052660, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:132 +0x199
net/http.(*persistConn).readLoop(0xc208086000)
/usr/local/go/src/net/http/transport.go:842 +0xff
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:660 +0x10d4
goroutine 9 [select]:
net/http.(*persistConn).writeLoop(0xc208086000)
/usr/local/go/src/net/http/transport.go:945 +0x4ff
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:661 +0x10f1
goroutine 12 [select]:
net/http.(*persistConn).writeLoop(0xc2080860b0)
/usr/local/go/src/net/http/transport.go:945 +0x4ff
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:661 +0x10f1
exit status 2
Hmm... sorry for the ping-pong, but now I'm curious. There is a nil pointer in your code that I don't have...
Which Go/OS version are you on? What's the output of go version and uname -a?
Also, if you're on Mac or Linux, can you compile the app with go build <code>.go and send me the binary so I can debug?
MAC OS X Yosemite 10.10
go version:
go version go1.4.2 darwin/amd64
uname -a:
Darwin Mac-Emilio 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Here you have the binary file ;)
https://www.dropbox.com/s/esjttgbp0qzsnzl/test_es.go?dl=0
Sorry, the link correct is: https://www.dropbox.com/s/kr7to6g6fr6k9gd/test_es?dl=0
Just tested it in a VM for an hour. No connection problems here. I'm afraid it must have something to do with your network/environment.
Can you rewrite the program with an official client e.g. in Python or Ruby? For example, run gem i elasticsearch, then run this program with ruby <program>.rb:
#!/usr/bin/env ruby
# encoding: utf-8
require 'elasticsearch'
while true
client = Elasticsearch::Client.new(log: true)
client.transport.reload_connections!
client.cluster.health
client = nil
sleep 1
end
@olivere i see this error consistently when the network is down or when there isn't a functional network connection or even when there is a slow network connection (tether phone). wonder its in our usage that triggers this..
Was able to reproduce this at least twice - mac/yosemite/go1.4
@vishalshah-org Thanks. Hmm, tried to go into Wifi mode but can't reproduce it. I'm using Network Link Conditioner from Hardware IO Tools for Xcode now to simulate a flaky/slow network. But cannot get it to fail (yet).
What's interesting is that according to the stack trace it fails when performing a HTTP request. And it's crashing with a nil pointer, not even returning an error. I'm curious what the error might be, but I'm not sure I can do anything in Elastic to prevent this from happening.
That's why it'd be interesting if it also fails when using e.g. Ruby, as that might show that it's something related to Go, either Elastic or net/http.
@dashaus Sorry for all the "spam" :-)
Besides the Ruby code, does this also yield the same problem?
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
var n int64
for {
n++
fmt.Printf("%d\r", n)
res, err := http.DefaultClient.Get("http://127.0.0.1:9200/")
if err != nil {
fmt.Printf("%v\n", err)
}
if res.StatusCode != 200 {
fmt.Printf("%s\n", res.StatusCode)
}
res.Body.Close()
time.Sleep(100*time.Millisecond)
}
}
Hmm... I could get it to fail with my example code. It happens if I connect to an IP that doesn't run ES. In my example code, there is a race in that I check an error but still continue. So the example runs on and then fails when doing the Ping. This is obviosuly a problem with my example code, so I have changed the gist. Does this still fail?
Also, I have pushed an issue-58 branch that enforces a check in NewClient, regardless if sniffing and/or healthchecks are enabled. I'm still investigating if there's another way to cause the problem.
@olivere I dont will be in my home to Monday. When i come back to home i will try it with your new instructions ;) . Thanks!
@olivere i was outside and thats where i consistently saw the error with my tethered network connection. Now, from home I am not able to reproduce it too even with a tethered connection.
will continue testing...
@olivere The ruby code works fine. The net/http code works fine too. The new code of gist file still fails, but not by a panic (appeared to me twice the message "no Elasticsearch node available" but then continues normally).
@olivere The error occurs in the sniff method of Client struct, in the <-time.After(timeout) case of select statement.
I changed the value of DefaultSnifferTimeout const to 1 * (time.Second * 4) and the error is never raised.
Ha! That sounds like a very plausible explanation. Unfortunately, I won't find the time in the next few days to check and fix it. It'll have to wait for next weekend.
On 6 April 2015 at 23:07, dashaus [email protected] wrote:
@olivere https://github.com/olivere The error occurs in the sniff method of Client struct, in the <-time.After(timeout) case of select statement.
I changed the value of DefaultSnifferTimeout const to 1 * (time.Second * 4) and the error is never raised.
— Reply to this email directly or view it on GitHub https://github.com/olivere/elastic/issues/58#issuecomment-90244314.
Just for self-reference: The official Ruby client uses a timeout of 1s, the JS client uses 3s. The Python client uses .1s, but doesn't use that value when starting up the client. Docs:
:arg sniff_timeout: timeout used for the sniff request - it should be a fast api call and we are talking potentially to more nodes so we want to fail quickly. Not used during initial sniffing (if
sniff_on_startis on) when the connection still isn't initialized.
I lean to the Python way of doing things: Robust startup and relaxing/fast when running. That'd mean a combination of the changes by @dashaus and the changes I made in branch issue-58.