Sarthak Agarwal
Sarthak Agarwal

Reputation: 444

Aerospike Java client EOFException

I am trying to connect to a Aerospike single node I set up using Vagrant on MacOSX. My AMC is running on localhost:2200. I am unable to connect to it successfully.

import com.aerospike.client.AerospikeClient;

public class AerospikeDriver {
    public static void main(String[] args) {
        AerospikeClient client = new AerospikeClient("127.0.0.1", 2200);
        client.close();
    }
}

I am getting this error in the first line itself. I tried changing the port to 3000 as well. Same error. Sometimes, I get SocketException as well.

Exception in thread "main" com.aerospike.client.AerospikeException$Connection: Error Code -8: Failed to connect to host(s): 
127.0.0.1 2200 Error Code -1: java.io.EOFException

    at com.aerospike.client.cluster.Cluster.seedNodes(Cluster.java:532)
    at com.aerospike.client.cluster.Cluster.tend(Cluster.java:425)
    at com.aerospike.client.cluster.Cluster.waitTillStabilized(Cluster.java:380)
    at com.aerospike.client.cluster.Cluster.initTendThread(Cluster.java:286)
    at com.aerospike.client.cluster.Cluster.<init>(Cluster.java:243)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:234)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:175)
    at AerospikeDriver.main(AerospikeDriver.java:5)

My maven dependency for aerospike client is this:

<dependency>
    <groupId>com.aerospike</groupId>
    <artifactId>aerospike-client</artifactId>
    <version>4.1.11</version>
</dependency>

This is my aerospike conf:

# Aerospike database configuration file.

# This stanza must come first.
service {
    user root
    group root
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    pidfile /var/run/aerospike/asd.pid
#   service-threads 4
#   transaction-queues 4
#   transaction-threads-per-queue 4
    proto-fd-max 15000
        node-id-interface eth1
}

logging {
    # Log file must be an absolute path.
    file /var/log/aerospike/aerospike.log {
        context any info 
    }
        file /var/log/aerospike/udf.log {
                context udf info
                context aggr info
        }
}

network {
    service {
        address eth1
        port 3000
#                access-address <Published IP>
#                access-address <NAT IP> 
    }

    heartbeat {
        mode multicast
                multicast-group 239.1.99.222
        address eth1 
        port 9918
                protocol v3

        # To use unicast-mesh heartbeats, comment out the 3 lines above and
        # use the following 4 lines instead.
#       mode mesh
#       port 3002
#       mesh-address 10.1.1.1
#       mesh-port 3002

        interval 150
        timeout 10
    }

    fabric {
        port 3001
                address eth1
    }


    info {
        port 3003
    }
}

#namespace test {
#   replication-factor 2
#   memory-size 4G
#   default-ttl 30d # 30 days, use 0 to never expire/evict.
#
#   storage-engine memory
#}

namespace test {
    replication-factor 2
    memory-size 2G
    default-ttl 5d # 5 days, use 0 to never expire/evict.

    # To use file storage backing, comment out the line above and use the
    # following lines instead.
    storage-engine device {
        file /opt/aerospike/data/test.dat
        filesize 5G
        data-in-memory true # Store data in memory in addition to file.
    }
}

What am I doing wrong? Need some help here. I am very new to aerospike. I tried searching everywhere, but couldn't find anything.

UPDATE

I am now using IP address 172.28.128.4 (got it from ifconfig command) and port 3000 to connect to aerospike. I am now getting Socket Timeout Exception.

Upvotes: 0

Views: 799

Answers (1)

pgupta
pgupta

Reputation: 5415

If you setup a single node on vagrant on Mac, and you running you are application in an ide on mac - say eclipse - locoalhost on vagrant is exposed to the mac as 172.28.128.3 typically. running ifconfig in your vagrant shell will confirm that. if your application is running inside vagrant itself, then 127.0.0.1 should work, in each case, your application should specify port 3000. thats where aerospike server is listening. amc is a webserver that talks to aerospike on port 3000 and serves the dashboard on port 8081 by default. so its a monitoring and management gateway to aerospike via a web browser. also, in your aerospike config, suggest you use mesh config instead of multicast though for a single node it does not matter - you are not making a cluster. If you are new, if you download CE, you get complimentary access to Aerospike Intro course in Aerospike Academy. Take advantage of that - few hours investment. Otherwise here are some intro videos on youtube. ( 02-Intro to Aerospike and 03-handson )

Upvotes: 1

Related Questions