xmemcached icon indicating copy to clipboard operation
xmemcached copied to clipboard

当使用的别名不是hosts内绑定的第一个时带auth请求失败

Open lujian0571 opened this issue 5 years ago • 0 comments

        String ip = "<IP>";
        int port = 11211;
        String user = "cacheuser";
        String password = "12345";
        InetSocketAddress inetSocketAddress = new InetSocketAddress(ip, port);
        XMemcachedClientBuilder memcachedClientBuilder = new XMemcachedClientBuilder(Arrays.asList(inetSocketAddress));
        memcachedClientBuilder.setConnectionPoolSize(3);
        memcachedClientBuilder.setCommandFactory(new BinaryCommandFactory());
        memcachedClientBuilder.setAuthInfoMap(Collections.singletonMap(inetSocketAddress, AuthInfo.plain(user, password)));
        MemcachedClient memcachedClient = memcachedClientBuilder.build();
        memcachedClient.set("aaa", 86400, "12345");
        String a2 = memcachedClient.get("aaa");
        System.out.println(a2);
  • 当hosts内存在

192.168.1.5 cache1

代码<IP>直接使用使用ip:192.168.1.5时会验证失败,使用cache1正常

  • 当hosts内存在
192.168.1.5 cache1
192.168.1.5 cache2

代码<IP>使用别名: cache2会验证失败,使用cache1正常


出错代码 AuthMemcachedConnectListener 内的

      AuthInfo authInfo =
          authInfoMap.get(AddrUtil.getServerString(tcpSession.getRemoteSocketAddress()));

取到null

lujian0571 avatar Sep 03 '19 07:09 lujian0571