How to solve AerospikeClient Error code 1

1

Upon creating AerospikeClient, I receive:

Aerospike.Client.AerospikeException.Connection
  HResult=0x80131500
  Message=Failed to connect to host(s): 
localhost 3000 Error -1: An established connection was aborted by the software in your host machine

I've created a new Aerospike container that runs on my local machine with port 3000 with the following command:

docker run -d -p 3000:3000 aerospike/aerospike-server

and I've manage to connect it with AerospikeClient & AQL with the following command:

docker run -it aerospike/aerospike-tools aql -h 172.17.0.2 -p 3000

later on I played with the docker container commands (stop and start) and it still worked.

now for some reason it does not work anymore, I still manage to connect with AQL but not with the AerospikeClient.

asClient = new AerospikeClient(HostName, Port); //throws Exception

this is the full exception log:

Source=AerospikeClient
  StackTrace:
   at Aerospike.Client.Cluster.SeedNodes(Boolean failIfNotConnected)
   at Aerospike.Client.Cluster.Tend(Boolean failIfNotConnected)
   at Aerospike.Client.Cluster.WaitTillStabilized(Boolean failIfNotConnected)
   at Aerospike.Client.Cluster.InitTendThread(Boolean failIfNotConnected)
   at RestaurantDecider.DataAccess.AerospikeRestaurantRepo..ctor() in C:\Users\etianc\source\repos\AeroSpikeDemo\RestaurantDecider.DataAccess\AerospikeRestaurantRepo.cs:line 28
   at AeroSpikeDemo.Program.Main(String[] args) in C:\Users\etianc\source\repos\AeroSpikeDemo\AeroSpikeDemo\Program.cs:line 30
c#
docker
.net-core
containers
aerospike
asked on Stack Overflow Jun 17, 2019 by Etian Chamay

1 Answer

3

I am not too familiar with Aerospike but from what I see you are running two separate containers - one is the "server" and the other is the client connecting to it. Things you need to consider when doing this without using docker-compose.yml

  1. Both containers need to be on the same network to be able to communicate with each other (I suggest using docker-compose if you have multi-service setup because it creates a special network for the project where all containers are attached by default)
  2. You shouldn't just hard-code the IP address and instead define a special hostname since the IP address can change depending on what IP's are already assigned to other networks/containers

If I were you I would just use a docker-compose.yml file similar to this:

version: "3"
services:
  server:
    image: aerospike/aerospike-server
  client:
    depends_on:
      - server
    image: aerospike/aerospike-tools
    command: ["aql", "-h", "172.17.0.2", "-p", "3000"]

But from what I see on the docker hub, you should use a custom configuration file and define access-address (see https://hub.docker.com/_/aerospike under access-address Configuration)

answered on Stack Overflow Jun 17, 2019 by Kārlis Ābele • edited Jun 20, 2019 by Kārlis Ābele

User contributions licensed under CC BY-SA 3.0