首页 > 解决方案 > 无法使用 c# 客户端连接 docker aerospike 服务器

问题描述

我是 aerospike 的新手。我已经使用 Docker 部署了 aerospike。下面是我用来部署 Aerospike 服务器的命令。

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

码头工人ps输出:

容器 ID 图像命令创建状态端口名称
1376791119a2 aerospike/aerospike-server "/entrypoint.sh asd" 13 分钟前 上升 13 分钟 0.0.0.0:3000->3000/tcp, 3001-3003/tcp aerospike1

但是,在连接时出现连接错误。

错误 :

错误-8:无法连接到主机:localhost 3000 错误-8:连接尝试失败,因为连接方在一段时间后没有正确响应,或建立连接失败,因为连接的主机没有响应

下面是我的代码

            // Establish connection the server
            AerospikeClient client = new AerospikeClient("localhost",3000);

            // Create key
            Key key = new Key("test", "credits", "123425");
            //Key key = new Key("test", "foo", "123");

            // Create Bins
            Bin bin1 = new Bin("name", "Sam");
            Bin bin2 = new Bin("age", 25);
            Bin bin3 = new Bin("gender", "Male");
            Bin bin4 = new Bin("department", "Engineering");

            // Write record
            client.Put(null, key, bin1, bin2, bin3, bin4);

            // Read record
            Record record = client.Get(null, key);
            string s = record.GetGeoJSON("");
            // Close connection
            client.Close();
        }
        catch (Exception ex)
        {

            Console.WriteLine(ex.ToString());
        }

标签: c#dockeraerospike

解决方案


推荐阅读