Invalid NEST response built from a unsuccessful () low level call on PUT: /indexname/_doc/888

Invalid NEST response built from a unsuccessful () low level call on PUT:

[1] BadRequest: Node: http://localhost:9200/ Took: 00:00:00.2651740

OriginalException: System.Net.Http.HttpRequestException: Cannot assign requested address

---> System.Net.Sockets.SocketException (99): Cannot assign requested address
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Elasticsearch.Net.HttpConnection.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken)




@EmpeRoar can you provide more details:

  1. how are you running Elasticsearch e.g. from zip, package, Docker?
  2. how are your running the .NET client application e.g. on Windows, MacOS, Linux, in Docker?
  3. version of .NET you are running e.g. .NET full framework, .NET Core? Version?

It's a SocketException coming from the underlying HTTP library attempting to connect to localhost on port 9200, which says to me this is likely a network configuration issue.

  1. I am running Elasticsearch using Docker via docker-compose .
    Elasticsearch dockerfile has this. :${ELK_VERSION}

  2. Im in windows 10 machine, but my .net is in core 3.0 via docker.

  3. .net core 3.0

If I am not running my .net app in the same docker network with elasticsearch I can be able to connect.

var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
settings.BasicAuthentication("elastic", "changeme");
var client = new ElasticClient(settings);
var asyncIndexResponse = await client.IndexDocumentAsync(customer);

but once I use docker to run my .net.. i cant be able to connect.
Im thinking that its because of http://localhost:9200, but changing it to elasticsearch name defined in docker-compose, its complaining that it cannot read the supplied uri.

var settings = new ConnectionSettings(new Uri("elasticsearch "))

my docker-compose looks like this.

image: tp3-customers
restart: on-failure
- 5011:80
- elasticsearch
- elk
context: elasticsearch/
- type: bind
source: ./elasticsearch/config/elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
read_only: true
- type: volume
source: elasticsearch
target: /usr/share/elasticsearch/data
- "9200:9200"
- "9300:9300"
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
- elk

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.