'Bad Connection Handle' for Aerospike


#1

I tried to integrate the Aerospike with Ejabberd, and after little bit of struggle and I had hit another issue which says


" DEBUG:[util_extract_common_lead_parms()]:Connection Handle is bad C(0) DEBUG:[util_extract_common_lead_parms()]:Connection Handle is bad C(32680) " I made the connection the following way,

-behaviour(gen_mod).
-define(CONN_NAME, 'ejabberd_aerospike_client').
init()->
   Host = "127.0.0.1", 
   Port = 3000,
  case aerospike:connect( Host, Port ) of
  {ok, C } ->
  register(?CONN_NAME,C),
 ok;
{error, _} = Err ->
  ?ERROR_MSG("failed to start aerospike client: ~p", [Err]),
  Err
 end.

#2

Can you validate whether or not the example(s) which comes with erlang client successfully run against your server?


#3

Yes, they(examples) did worked well as standalone. The module which I wrote for Ejabberd to connect with clues from Examples didnt work and throws this exception.


#4

I tried couple of ways to make it work. And finally the root cause is,

register(?CONN_NAME,C),

is failing with bad argument. but the same register will work if i give like

register(?CONN_NAME,self()),

W.r.t aerospike if I create a fresh connection for each insertion it worked (its a overkill). You can give a try for this on ‘helloWorld.erl’ by yourself.

Is this a bug in the erlang driver or am I missing some some good practice (as I’m new to this erlang world) which I have to take care of.

Awaiting for response.


#5

From the Erlang documentation, the register/2 function will only take valid pid or port number. http://erlang.org/doc/man/erlang.html#register-2

The cluster object C returned by aerospike:connect() is an opaque object.

You are correct in seeking a way to only create the cluster object only once, and reuse it subsequently on all aerospike calls. Knowledge of doing this in the ejabberd environment is likely best found with experts in that community.