Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to ElasticSearch running inside Docker fails (MacOS) #3708

Open
moodyjon opened this issue Jul 29, 2022 · 0 comments · May be fixed by #3709
Open

Connection to ElasticSearch running inside Docker fails (MacOS) #3708

moodyjon opened this issue Jul 29, 2022 · 0 comments · May be fixed by #3709

Comments

@moodyjon
Copy link
Contributor

moodyjon commented Jul 29, 2022

I am running lbry-sdk integration tests locally on MacOS, with elastic-search inside Docker. I used the lbry-sdk/Makefile command to launch it:

elastic-docker:
	docker run -d -v lbryhub:/usr/share/elasticsearch/data -p 9200:9200 -p 9300:9300 -e"ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.1

In order to connect herald -> elastic-search, I had to disable the SetSniff() option.

diff --git a/server/server.go b/server/server.go
index 415b728..7706e72 100644
--- a/server/server.go
+++ b/server/server.go
@@ -210,7 +210,7 @@ func MakeHubServer(ctx context.Context, args *Args) *Server {
        if !args.DisableEs {
                esUrl := args.EsHost + ":" + args.EsPort
                opts := []elastic.ClientOptionFunc{
-                       elastic.SetSniff(true),
+                       elastic.SetSniff(false),
                        elastic.SetSnifferTimeoutStartup(time.Second * 60),
                        elastic.SetSnifferTimeout(time.Second * 60),
                        elastic.SetURL(esUrl),

Probably the clearest explanation:
olivere/elastic#1138

More similar issues:
https://github.com/olivere/elastic/issues?q=is%3Aissue+docker+SetSniff+SetHealthCheck

Making a --nosniff option MAY NOT be the best solution here. I found the following comment describes how to fix this using the network.publish_host option of ElasticSearch. olivere/elastic#824 (comment)

Example:
docker run --env network.publish_host=127.0.0.1 ...

I tested "--env network.publish_host=127.0.0.1" and it worked for me.

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#advanced-network-settings

Symbolic addresses like network.publish_host=_local_ are supported.

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#network-interface-values

@moodyjon moodyjon transferred this issue from lbryio/herald.go Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant