But if I create another connection in go procedure itself (in the same way as I do in main() ) then all goes fine.
Some pieces of my code:
// ESHost Elasticsearch host
var ESHost = flag.String("eshost", "localhost", "Elasticsearch Server Host Address")
// ESPort Elasticsearch port
var ESPort = flag.String("esport", "9200", "Elasticsearch Server Port Address")
// ESIndex Elasticsearch index name
var ESIndex = flag.String("esindex", "websites", "Elasticsearch Index Name")
// ESCon Elasticsearch connection
var ESCon *elastigo.Conn
// WG for waiting for all threads to complete
var WG sync.WaitGroup
func main() {
flag.Parse()
ESCon := elastigo.NewConn()
ESCon.Domain = *ESHost
ESCon.Port = *ESPort
_, err := ESCon.Count(*ESIndex, "product", nil, nil) // it all is fine here
if err != nil {
checkErr(err)
}
// then I create a pull of background workers..
// and try to reuse ESCon in there ( ESCon.Index(..) ), but it fails with the error above
}
Getting this error when trying to reuse connection from another go procedure:
But if I create another connection in go procedure itself (in the same way as I do in main() ) then all goes fine.
Some pieces of my code: