memcached client: connection failure

603 views
Skip to first unread message

black...@gmail.com

unread,
Jul 16, 2016, 5:36:18 AM7/16/16
to Hazelcast
Hello all,

I'm trying to use hazelcast (3.6.3) together with libmemcached (1.0.18). I try a simple set command and always get an CONNECTION FAILURE. Is the memcached support broken? I also tried the python-memcached module with the same result. Connecting with a real memcached daemon works fine.

Here is my source code (compile with gcc test.c -l memcached):

#include <libmemcached/memcached.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv) {
  memcached_server_st *servers = NULL;
  memcached_st *memc;
  memcached_return rc;
  char *key = "keystring";
  char *value = "keyvalue";

  size_t value_length;
  uint32_t flags;

  memc = memcached_create(NULL);
  servers = memcached_server_list_append(servers, "localhost", 5701, &rc);
  rc = memcached_server_push(memc, servers);

  if (rc == MEMCACHED_SUCCESS)
    fprintf(stderr, "Added server successfully\n");
  else
    fprintf(stderr, "Couldn't add server: %s\n", memcached_strerror(memc, rc));

  rc = memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)3600);

  if (rc == MEMCACHED_SUCCESS)
    fprintf(stderr, "Key stored successfully\n");
  else
    fprintf(stderr, "Couldn't store key: %s\n", memcached_strerror(memc, rc));

  return 0;
}

The output of the client:

Added server successfully
Couldn't store key: CONNECTION FAILURE

The server output:

Jul 16, 2016 11:12:59 AM com.hazelcast.nio.tcp.SocketAcceptorThread
INFO: [172.16.243.141]:5701 [dev] [3.6.3] Accepting socket connection from /127.0.0.1:36681
Jul 16, 2016 11:12:59 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [172.16.243.141]:5701 [dev] [3.6.3] Established socket connection between /127.0.0.1:5701 and /127.0.0.1:36681
Jul 16, 2016 11:12:59 AM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [172.16.243.141]:5701 [dev] [3.6.3] Connection [/127.0.0.1:36681] lost. Reason: Socket explicitly closed

Both the client and the server are running on the same host. Can anybody explain what's happening?  Is hazelcast's memcached support broken?

Thanks,
Tom.

Emrah Kocaman

unread,
Jul 16, 2016, 8:43:11 AM7/16/16
to haze...@googlegroups.com
Hi Tom,

Memcache client support is disabled by default. Have you set "hazelcast.memcache.enabled" system property to "true" on your Hazelcast servers?

Best,

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/9959fd61-ef83-4c82-9ef6-bc3f7ed2938a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

black...@gmail.com

unread,
Jul 17, 2016, 5:54:16 AM7/17/16
to Hazelcast
Hello all,

I'm trying to use hazelcast (3.6.3) together with libmemcached (1.0.18). I try a simple set command and always get an CONNECTION FAILURE. I also tried the python-memcached module with the same result. Connecting with a real memcached daemon works fine.

Noctarius

unread,
Jul 17, 2016, 6:58:17 AM7/17/16
to Christoph Engelbert - Hazelcast
Hey Tom,

Did you explicitly activate memcached protocol? This was deactivated with Hazelcast 3.6 by default for security reasons. To activate it please see: http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#memcache-client. More specifically the last paragraph of the chapter, talking about “hazelcast.memcache.enabled”.

Chris


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.

black...@gmail.com

unread,
Jul 18, 2016, 2:45:14 PM7/18/16
to Hazelcast
Thanks a lot guys! This solved my issue.

Best regards
Tom
Reply all
Reply to author
Forward
0 new messages