edescourtis / ebitcoind

Erlang to Bitcoind API
GNU Lesser General Public License v3.0
23 stars 15 forks source link

noproc gen_server call error #3

Closed solatis closed 9 years ago

solatis commented 9 years ago

Hello,

I must be doing something wrong, since the example on the site is not working. Consider the following:

lmergen@laptop ~/git/ebitcoind $ bitcoin-cli getbalance
0.00000000
lmergen@laptop ~/git/ebitcoind $ erl -pa ebin deps/*/ebin
Erlang/OTP 17 [erts-6.4.1.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.4.1.2  (abort with ^G)
1> {ok,Pid} = ebitcoind:start_link().
{ok,<0.35.0>}
2> ebitcoind:getbalance(Pid).

=ERROR REPORT==== 12-Sep-2015::17:54:01 ===
** Generic server <0.35.0> terminating
** Last message in was getbalance
** When Server state == {state,
                            {bitcoin_jsonrpc_config,<<"bitcoinrpc">>,
                                <<"changeme">>,<<"127.0.0.1">>,8332,false},
                            <<213,147,216,99,51,224,110,206,177,55,123,191,
                              166,28,116,142>>}
** Reason for termination ==  
** {{noproc,
        {gen_server,call,
            [httpc_manager,
             {request,
                 {request,undefined,<0.35.0>,0,http,
                     {"127.0.0.1",8332},
                     "/",[],post,
                     {http_request_h,undefined,"keep-alive",undefined,
                         undefined,undefined,undefined,undefined,undefined,
                         undefined,undefined,undefined,undefined,undefined,
                         "Basic Yml0Y29pbnJwYzpjaGFuZ2VtZQ==",undefined,
                         undefined,"127.0.0.1:8332",undefined,undefined,
                         undefined,undefined,undefined,undefined,undefined,
                         undefined,undefined,[],undefined,undefined,undefined,
                         undefined,"0",undefined,undefined,undefined,
                         undefined,undefined,undefined,[]},
                     {"application/json",
                      <<"{\"jsonrpc\":\"2.0\",\"method\":\"getbalance\",\"params\":[],\"id\":\"1ZPYYzPgbs6xN3u/phx0jg==\"}">>},
                     {http_options,"HTTP/1.1",30000,true,
                         {essl,[]},
                         undefined,false,3000,false},
                     "http://127.0.0.1:8332/",[],none,[],1442055241870,
                     undefined,undefined,false}},
             infinity]}},
    [{gen_server,call,3,[{file,"gen_server.erl"},{line,190}]},
     {httpc,handle_request,9,[{file,"httpc.erl"},{line,572}]},
     {ebitcoind,do_jsonrpc_request,2,[{file,"src/ebitcoind.erl"},{line,1090}]},
     {ebitcoind,handle_rpc_request,3,[{file,"src/ebitcoind.erl"},{line,1000}]},
     {gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
     {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
** exception exit: {noproc,{gen_server,call,
                                       [httpc_manager,
                                        {request,{request,undefined,<0.35.0>,0,http,
                                                          {"127.0.0.1",8332},
                                                          "/",[],post,
                                                          {http_request_h,undefined,"keep-alive",undefined,undefined,
                                                                          undefined,undefined,undefined,undefined,undefined,...},
                                                          {"application/json",
                                                           <<"{\"jsonrpc\":\"2.0\",\"method\":\"g"...>>},
                                                          {http_options,"HTTP/1.1",30000,true,
                                                                        {essl,[]},
                                                                        undefined,false,3000,...},
                                                          "http://127.0.0.1:8332/",[],none,[],1442055241870,undefined,
                                                          undefined,false}},
                                        infinity]}}
3>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution

I tried debugging this issue, but am kinda in a dead end, given I'm quite new to erlang. As seen above, I'm running erlang 17. Googling suggest there might be something wrong with the way the link is stored. Is this perhaps an erlang version compatibility issue ?

solatis commented 9 years ago

My inexperience at work here. I had to start inets like this:

inets:start().

before invoking any ebitcoind commands.

edescourtis commented 9 years ago

Add it as a dependency to your existing rebar project.