#1587·elastic

no available connection: no Elasticsearch node available

Author: wilcanCreated Feb 18, 2022Updated Mar 7, 2024

Which version of Elastic are you using?

[x] elastic.v7 (for Elasticsearch 7.x) [ ] elastic.v6 (for Elasticsearch 6.x) [ ] elastic.v5 (for Elasticsearch 5.x) [ ] elastic.v3 (for Elasticsearch 2.x) [ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

when I connect es successfully ,it will be fine.

Please describe the actual behavior

Sometimes ,when I connect the elasticsearch,there is a problem that no available connection and no Elasticsearch node available。 I view the source code,the actual problem may be

// next returns the next available connection, or ErrNoClient.
func (c *Client) next() (*conn, error) {
	
	// We tried hard, but there is no node available
	return nil, errors.Wrap(ErrNoClient, "no available connection")
}

Any steps to reproduce the behavior?

when I connect the es

	client, err := elastic.NewClient(
		elastic.SetSniff(false),
		elastic.SetURL(e.Url), // url:(http://xxx.xxx.xx)
		elastic.SetBasicAuth(e.Username, e.Password),
	)

there is a problem that ........

	bulkRequest := client.Bulk()
	for _, v := range data {
		tmp := v
		req := elastic.NewBulkIndexRequest().Index(s.EIndex).Id(v.Id).Doc(tmp)
		bulkRequest = bulkRequest.Add(req)
	}

	resp, err := bulkRequest.Do(context.Background())