basho / riak-erlang-client

The Riak client for Erlang.
Apache License 2.0
311 stars 188 forks source link

Disconnecting from riak node after some time #374

Closed blacklightknight closed 6 years ago

blacklightknight commented 6 years ago

Hello, I have just started using riak and am using riak-erlang-client. I follow the guide given here https://github.com/basho/riak-erlang-client/ but after some time I am getting disconnected from riak. Here are the console logs:

erl -pa riak-erlang-client/ebin/ riak-erlang-client/deps/*/ebin
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] [dtrace]

Eshell V8.0  (abort with ^G)
1> {ok,Pid} = riakc_pb_socket:start_link("192.168.1.29",8087).
** exception error: undefined function riakc_pb_socket:start_link/2
2> q().
ok
3> Admins-Mac-mini:riak-2.2.3 admin$ cd ..
Admins-Mac-mini:~ admin$ erl -pa riak-erlang-client/ebin/ riak-erlang-client/deps/*/ebin
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false] [dtrace]

Eshell V8.0  (abort with ^G)
1> {ok,Pid} = riakc_pb_socket:start_link("192.168.1.19",8087).
{ok,<0.58.0>}
2> riakc_pb_socket:ping(Pid).
pong
3> Object = riakc_obj:new(Pid,<<"mybucket">>,<<"mykey">>,<<"Val1 , Val2">>).
** exception error: no function clause matching 
                    riakc_obj:build_client_object(<0.58.0>,<<"mybucket">>,
                                                  <<"mykey">>) (src/riakc_obj.erl, line 153)
     in function  riakc_obj:new/4 (src/riakc_obj.erl, line 143)
4> Object = riakc_obj:new(<<"mybucket">>,<<"mykey">>,<<"Val1 , Val2">>).    
{riakc_obj,<<"mybucket">>,<<"mykey">>,undefined,[],
           undefined,<<"Val1 , Val2">>}
5> riakc_pb_socket:put(Pid,Object).                                     
** exception exit: {noproc,
                    {gen_server,call,
                     [<0.58.0>,
                      {req,
                       {rpbputreq,<<"mybucket">>,<<"mykey">>,undefined,
                        {rpbcontent,<<"Val1 , Val2">>,undefined,undefined,
                         undefined,undefined,[],undefined,undefined,[],[],
                         undefined,undefined},
                        undefined,undefined,undefined,undefined,undefined,
                        undefined,undefined,undefined,undefined,undefined,
                        undefined,undefined},
                       60000},
                      infinity]}}
     in function  gen_server:call/3 (gen_server.erl, line 212)
6> riakc_pb_socket:ping(Pid).                                               
** exception exit: {noproc,
                       {gen_server,call,
                           [<0.58.0>,{req,rpbpingreq,60000},infinity]}}
     in function  gen_server:call/3 (gen_server.erl, line 212)
7> 

Can anybody explain why am I getting the exception in line 6 and how can I get rid of it. I am running riak-2.2.3, a single node in a Mac .

russelldb commented 6 years ago

Hi, the riak user mailing list or IRC are the best place for questions like this. This is not an issue with the riak client.

When you call start_link you've linked your shell to the riak pb client Pid. When you have the error on line 3 you actually crashed the shell and restarted a new one, and your linked pb client Pid was crashed. There is no longer a riak_pb_client process running.

On line 5 you call PUT and the error messages tells you that there is noproc (no process). This is because the error on line 3 crashed it.

HTH, please use the ML or IRC or Slack next time

Russell

blacklightknight commented 6 years ago

Actually the first 3 lines of the logs are from a previous trail which should have failed due to a silly mistake which I figured out(my system restarted and thus my ip changed). These three lines shouldn't be here --my bad, but the next 6 lines are the actual logs, so the doubt still prevails but you are right i will ask this question in mailing list again. Sorry for the inconvenience caused here.