I am trying to communicate with a rabbitmq server from my mongooseim server. For that first I copied rabbitmq-client library (for erlang) to my apps directory, updated my makefile and then recompiled mongooseim code. (as per the instruction from here). This way I can compile the code with no error and can see amqp_client has been started from mongooseim console. Now when I try to run amqp_connection:start() from the console I get the below error. How to fix this?
(mongooseim#localhost)8> {ok, Connection} = amqp_connection:start(#amqp_params_network{}).
2015-04-23 15:07:27.320 [debug] <0.790.0> Supervisor {<0.790.0>,amqp_connection_sup} started amqp_connection_type_sup:start_link() at pid <0.791.0>
2015-04-23 15:07:27.324 [debug] <0.790.0> Supervisor {<0.790.0>,amqp_connection_sup} started amqp_gen_connection:start_link(<0.791.0>, {amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,none,[#Fun<amq..>,...],...}) at pid <0.792.0>
** exception exit: {{function_clause,[{amqp_gen_connection,terminate,
[{undef,[{rabbit_net,connection_string,
[#Port<0.6063>,outbound],
[]},
{amqp_network_connection,try_handshake,3,[]},
{amqp_gen_connection,handle_call,3,[]},
{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}]}]},
{<0.791.0>,
#amqp_params_network{username = <<"guest">>,
password = <<"guest">>,virtual_host = <<"/">>,
host = "localhost",port = 5672,channel_max = 0,
frame_max = 0,heartbeat = 0,connection_timeout = infinity,
ssl_options = none,
auth_mechanisms = [#Fun<amqp_auth_mechanisms.plain.3>,
#Fun<amqp_auth_mechanisms.amqplain.3>],
client_properties = [],socket_options = []}}],
[]},
{gen_server,try_terminate,3,
[{file,"gen_server.erl"},{line,621}]},
{gen_server,terminate,7,
[{file,"gen_server.erl"},{line,787}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,237}]}]},
{gen_server,call,[<0.792.0>,connect,infinity]}}
in function gen_server:call/3 (gen_server.erl, line 190)
(mongooseim#localhost)9> 2015-04-23 15:07:27.411 [error] <0.792.0> gen_server <0.792.0> terminated with reason: no function clause matching amqp_gen_connection:terminate({undef,[{rabbit_net,connection_string,[#Port<0.6063>,outbound],[]},{amqp_network_connection,try_handshake,...},...]}, {<0.791.0>,{amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,...}})
2015-04-23 15:07:27.412 [error] <0.792.0> CRASH REPORT Process <0.792.0> with 0 neighbours exited with reason: no function clause matching amqp_gen_connection:terminate({undef,[{rabbit_net,connection_string,[#Port<0.6063>,outbound],[]},{amqp_network_connection,try_handshake,...},...]}, {<0.791.0>,{amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,...}}) in gen_server:terminate/7 line 792
2015-04-23 15:07:27.414 [error] <0.790.0> Supervisor {<0.790.0>,amqp_connection_sup} had child connection started with amqp_gen_connection:start_link(<0.791.0>, {amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,none,[#Fun<amq..>,...],...}) at <0.792.0> exit with reason no function clause matching amqp_gen_connection:terminate({undef,[{rabbit_net,connection_string,[#Port<0.6063>,outbound],[]},{amqp_network_connection,try_handshake,...},...]}, {<0.791.0>,{amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,...}}) in context child_terminated
2015-04-23 15:07:27.416 [error] <0.790.0> Supervisor {<0.790.0>,amqp_connection_sup} had child connection started with amqp_gen_connection:start_link(<0.791.0>, {amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,"localhost",5672,0,0,0,infinity,none,[#Fun<amq..>,...],...}) at <0.792.0> exit with reason reached_max_restart_intensity in context shutdown
The undef error message tells us that the rabbit_net module or the connection_string function is missing and rabbit_net is a part of rabbit_common package. I guess you didn't add rabbit_common. You can find the package on the website you pasted in the previous question - here. Repeat the steps with rabbit_common.ez and it should work.
Related
I'm new in Erlang and telefony stuff. I'm trying to wake up an iOS app by a push notification sent by Pusher, a Kazoo module that use apns4erl to do the job.
When Pusher try to send a notification, It should start the apns but it get this error:
10:44:22.756 [error] |0000000000|Undefined:Undefined(<0.29186.843>) gen_statem 'apns_com.test.viavoip' in state connected terminated with reason: {'function not exported',{string,lowercase,1}} in gun:normalize_headers/1 line 661
10:44:22.756 [error] |0000000000|string:Undefined(<0.29186.843>) CRASH REPORT Process 'apns_com.test.viavoip' with 0 neighbours crashed with reason: call to undefined function string:lowercase(<<"apns-topic">>)
10:44:22.756 [error] |0000000000|Undefined:Undefined(<0.26408.843>) Supervisor apns_sup had child apns_connection started with {apns_connection,start_link,undefined} at <0.29186.843> exit with reason undef in context child_terminated
10:44:22.760 [error] |0000000000|Undefined:Undefined(<0.31997.843>) gen_server pm_apple terminated with reason: {undef,{gen_statem,call,[<0.29186.843>,{push_notification,<<"ac79eb0d7f28ee04d3539b80a3b6f519cc3db78e7b3840f18b497fadcedc5264">>,<<"{\"aps\":{\"alert\":{\"loc-args\":[\"1089 - Dario Test3\"],\"loc-key\":\"IC_SIL\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"sound\":\"ring.caf\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"caller-id-name\":\"Dario Test3\",\"caller-id-number\":\"1089\",\"proxy\":\"sip:94.138.35.201:5060\",\"registration-token\":\"4ad4ad69-6939-4f04-ada6-e827983a4b23\",\"utc_unix_timestamp_ms\":\"16...">>,...},...]}} in gen:do_call/4 line 177
10:44:22.760 [error] |0000000000|Undefined:Undefined(<0.31997.843>) CRASH REPORT Process pm_apple with 0 neighbours exited with reason: {undef,{gen_statem,call,[<0.29186.843>,{push_notification,<<"ac79eb0d7f28ee04d3539b80a3b6f519cc3db78e7b3840f18b497fadcedc5264">>,<<"{\"aps\":{\"alert\":{\"loc-args\":[\"1089 - Dario Test3\"],\"loc-key\":\"IC_SIL\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"sound\":\"ring.caf\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"caller-id-name\":\"Dario Test3\",\"caller-id-number\":\"1089\",\"proxy\":\"sip:94.138.35.201:5060\",\"registration-token\":\"4ad4ad69-6939-4f04-ada6-e827983a4b23\",\"utc_unix_timestamp_ms\":\"16...">>,...},...]}} in gen_server:terminate/7 line 812
10:44:22.761 [error] |0000000000|Undefined:Undefined(<0.30380.843>) Supervisor pusher_module_sup had child pm_apple started with pm_apple:start_link() at <0.31997.843> exit with reason {undef,{gen_statem,call,[<0.29186.843>,{push_notification,<<"ac79eb0d7f28ee04d3539b80a3b6f519cc3db78e7b3840f18b497fadcedc5264">>,<<"{\"aps\":{\"alert\":{\"loc-args\":[\"1089 - Dario Test3\"],\"loc-key\":\"IC_SIL\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"sound\":\"ring.caf\"},\"call-id\":\"2d25fee2-74d9-43c7-9bfe-90a167f5941a\",\"caller-id-name\":\"Dario Test3\",\"caller-id-number\":\"1089\",\"proxy\":\"sip:94.138.35.201:5060\",\"registration-token\":\"4ad4ad69-6939-4f04-ada6-e827983a4b23\",\"utc_unix_timestamp_ms\":\"16...">>,...},...]}} in context child_terminated
It seems that the apns cannot start because of this: string:lowercase(<<"apns-topic">>).
In erl console this command works fine, maybe there is few dependences with a wrong version or some wrong comfiguration.
Any advise?
I am using erlang client library to connect to local rabbitmq server using default connection parameters. I am getting this issue in a span of arroung Once in 24 Hours. My Erlang Application Not Able to Handle This Issue.
For My Error Logger I Getting These Message..
2017-08-06 12:45:03.883 [error] <0.3739.0>#rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3739.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:03.883 [error] <0.3736.0> Supervisor {<0.3736.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2798>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3738.0>, {<<"client 127.0.0.1:56646 -> 127.0.0.1:5672">>,1}) at <0.3739.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:03.900 [error] <0.3736.0> Supervisor {<0.3736.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2798>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3738.0>, {<<"client 127.0.0.1:56646 -> 127.0.0.1:5672">>,1}) at <0.3739.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:04.514 [error] <0.3754.0>#rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3754.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:04.514 [error] <0.3751.0> Supervisor {<0.3751.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2819>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3753.0>, {<<"client 127.0.0.1:49559 -> 127.0.0.1:5672">>,1}) at <0.3754.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:04.515 [error] <0.3751.0> Supervisor {<0.3751.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2819>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3753.0>, {<<"client 127.0.0.1:49559 -> 127.0.0.1:5672">>,1}) at <0.3754.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:04.846 [error] <0.3768.0>#rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3768.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:04.846 [error] <0.3765.0> Supervisor {<0.3765.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2821>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3767.0>, {<<"client 127.0.0.1:60413 -> 127.0.0.1:5672">>,1}) at <0.3768.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:04.846 [error] <0.3765.0> Supervisor {<0.3765.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2821>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3767.0>, {<<"client 127.0.0.1:60413 -> 127.0.0.1:5672">>,1}) at <0.3768.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:05.154 [error] <0.3782.0>#rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3782.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:05.154 [error] <0.3779.0> Supervisor {<0.3779.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2823>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3781.0>, {<<"client 127.0.0.1:36301 -> 127.0.0.1:5672">>,1}) at <0.3782.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:05.154 [error] <0.3779.0> Supervisor {<0.3779.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2823>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3781.0>, {<<"client 127.0.0.1:36301 -> 127.0.0.1:5672">>,1}) at <0.3782.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:05.484 [error] <0.3796.0>#rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3796.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:05.484 [error] <0.3793.0> Supervisor {<0.3793.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2825>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3795.0>, {<<"client 127.0.0.1:34055 -> 127.0.0.1:5672">>,1}) at <0.3796.0> exit with reason badarg in context child_terminated
I am using this Library
https://github.com/jbrisbin/amqp_client
as it having rebar. And I am using rebar for my project .
May Be I written some thing wrong, As I am very new to erlang. And this is my First project Live in Erlang. I am using ranch as tcp client Acceptor. And My Client Handler is a gen_fsm.
code snipet what I am using
init({Ref, Socket, Transport, Mod, _Opts=[]})->
process_flag(trap_exit, true),
ok = ranch:accept_ack(Ref),
ok = Transport:setopts(Socket, [{active, once}]),
{ok, {RemoteIp, _Port}} = inet:peername(Socket),
lager:info("New Client Connection From ~w Socket ~w", [RemoteIp, Socket]),
{ok, RabbitConnection} = amqp_connection:start(#amqp_params_network{}),
{ok, RabbitChannel} = amqp_connection:open_channel(RabbitConnection),
InitTimerRef = erlang:start_timer(30000, self(), session_init_timer_laps),
gen_fsm:enter_loop(?MODULE, [], open, #state{socket=Socket, transport=Transport, buffer= <<>>, mod=Mod, timers=#session_timers{session_init_timer=InitTimerRef}, sequence_number=1, rabbitmq_conn=RabbitConnection, rabbitmq_channel=RabbitChannel, remote_ip=RemoteIp}).
Also when ever I am getting this Issue My ranch socket Listener throwing below errors.
<0.815.0> Ranch acceptor reducing accept rate: out of file descriptors
you ran out of file descriptors it means that you are opening too much resource without close them (Most likely connections).
you can increase your file descriptors, but you need to monitor your client and check the resources it is using.
NOTE the client you are using is a bit old, the official amqp rabbitmq client is on hex repository. (https://hex.pm/packages/amqp_client)
You should use it on your project:
{amqp_client, "3.6.10"}
I am trying connect to rabbitmq using amqp_client library. I followed the steps provided here.
My rabbitmq version is RabbitMQ 3.5.7, Erlang 18.3. So I downloaded respective files from https://www.rabbitmq.com/releases/rabbitmq-erlang-client/v3.5.7/. and unzipped to "/usr/lib/erlang/lib/" path. then in erlang shell i started like below
application:start(xmerl).
application:start(amqp_client).
application:start(rabbit_common).
rr("/usr/lib/erlang/lib/amqp_client-3.5.7/include/amqp_client.hrl").
#amqp_params_network{}.
{ok, Connection} = amqp_connection:start(#amqp_params_network{port=5672}).
In this step I got Some crash report
=ERROR REPORT==== 3-Feb-2017::18:55:10 ===
** Generic server <0.99.0> terminating
** Last message in was connect
** When Server state == {<0.98.0>,
{amqp_params_network,<<"guest">>,<<"guest">>,
<<"/">>,"localhost",5672,0,0,10,infinity,none,
[#Fun<amqp_auth_mechanisms.plain.3>,
#Fun<amqp_auth_mechanisms.amqplain.3>],
[],[]}}
** Reason for termination ==
** {function_clause,
[{amqp_gen_connection,terminate,
[{undef,
[{rabbit_misc,ntoab,[{127,0,0,1}],[]},
{rabbit_net,connection_string,2,[]},
{amqp_network_connection,try_handshake,3,[]},
{amqp_gen_connection,handle_call,3,[]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,629}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,661}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,240}]}]},
{<0.98.0>,
{amqp_params_network,<<"guest">>,<<"guest">>,<<"/">>,
"localhost",5672,0,0,10,infinity,none,
[#Fun<amqp_auth_mechanisms.plain.3>,
#Fun<amqp_auth_mechanisms.amqplain.3>],
[],[]}}],
[]},
{gen_server,try_terminate,3,[{file,"gen_server.erl"},{line,643}]},
{gen_server,terminate,7,[{file,"gen_server.erl"},{line,809}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
** exception exit: {{function_clause,
[{amqp_gen_connection,terminate,
[{undef,
[{rabbit_misc,ntoab,[{127,0,0,1}],[]},
{rabbit_net,connection_string,2,[]},
{amqp_network_connection,try_handshake,3,[]},
{amqp_gen_connection,handle_call,3,[]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,629}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,661}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,240}]}]},
{<0.98.0>,
#amqp_params_network{
username = <<"guest">>,password = <<"guest">>,
virtual_host = <<"/">>,host = "localhost",port = 5672,
channel_max = 0,frame_max = 0,heartbeat = 10,
connection_timeout = infinity,ssl_options = none,
auth_mechanisms =
[#Fun<amqp_auth_mechanisms.plain.3>,
#Fun<amqp_auth_mechanisms.amqplain.3>],
client_properties = [],socket_options = []}}],
[]},
{gen_server,try_terminate,3,
[{file,"gen_server.erl"},{line,643}]},
{gen_server,terminate,7,
[{file,"gen_server.erl"},{line,809}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,240}]}]},
{gen_server,call,[<0.99.0>,connect,infinity]}}
in function gen_server:call/3 (gen_server.erl, line 212)
I am not getting why I am getting this error?
[{undef,[{rabbit_misc means that it can't find the function.
you should try to execute the program using erl -pa /your_path_beam and put there all the .beam files.
Another way is to use rebar3 where you can easily create and app and the add amqp_client dependency ( from https://hex.pm/).
It is very similar to java maven
I use rabbitmq-erlang-client rabbitmq_2.7.0 in my production env. Recently, I have found some error as "unexpected_delivery_and_no_default_consumer" in my server app log.
2016-08-26 15:25:00.465 [error] CRASH REPORT Process with 0 neighbours exited with reason: {unexpected_delivery_and_no_default_consumer,{gen_server2,call,[,{consumer_call,{'basic.deliver',>,15804,false,>,>},{amqp_msg,{'P_basic',undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined},>}},infinity]}} in gen_server:terminate/7 line 826
rabbitmq consumer res:
rabbitmqctl list_consumers
Why "amq.ctag-2I715Fu1Q2m9AHgrhlN1Og" is not in the consumers tags?
PS:
1. I do not use the method 'basic.cancel'.
2. I config the msg as "no_ack = true"
英语不好,请见谅!!!!
I use the poolboy as my database connection pools,i have read the README.md on the github:https://github.com/devinus/poolboy
But at last i do not konw where i have started the poolboy when i want it to start,then i got an error:already_started
My project's files:http://pastebin.com/zus6dGdz
I use the cowboy to be my http server,but you can ignore it.
I start the program like this:
1.I use the rebar to compile
$rebar clean & make
2.then i use the erl to run my program
$ erl -pa ebin/ -pa deps/*/ebin -s start server_start
But i got the errors as follows:
=CRASH REPORT==== 3-Feb-2015::17:47:27 ===
crasher:
initial call: poolboy:init/1
pid: <0.171.0>
registered_name: []
exception exit: {{badmatch,{error,{already_started,<0.173.0>}}},
[{poolboy,new_worker,1,
[{file,"src/poolboy.erl"},{line,260}]},
{poolboy,prepopulate,3,
[{file,"src/poolboy.erl"},{line,281}]},
{poolboy,init,3,[{file,"src/poolboy.erl"},{line,143}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,306}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,237}]}]}
in function gen_server:init_it/6 (gen_server.erl, line 330)
ancestors: [hello_erlang_sup,<0.66.0>]
messages: []
links: [<0.172.0>,<0.173.0>,<0.170.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 610
stack_size: 27
reductions: 205
neighbours:
neighbour: [{pid,<0.173.0>},
{registered_name,db_mongo_handler},
{initial_call,{db_mongo_handler,init,['Argument__1']}},
{current_function,{gen_server,loop,6}},
{ancestors,[<0.172.0>,mg_pool1,hello_erlang_sup,<0.66.0>]},
{messages,[]},
{links,[<0.172.0>,<0.174.0>,<0.171.0>]},
{dictionary,[]},
{trap_exit,false},
{status,waiting},
{heap_size,233},
{stack_size,9},
{reductions,86}]
Please help to solve the problem!Ths!
You are starting a pool of 10 workers with the same registered name. When a process is registered with a name and another process tries to register with the same name, you get the error already_started.
In your example code, the worker module for poolboy is db_mongo_handler. Poolboy tries to start 10 workers by calling db_mongo_handler:start_link/1 which is implemented as
start_link(Args) ->
gen_server:start_link({local, ?SERVER}, ?MODULE, Args, []).
The first worker can start but when the second worker starts it crashes with already_started.
Normally the workers of a pool of many similar workers should not have a registered name. Instead, only the pool has a name and when you need a worker, you ask poolboy to deliver a pid() of one of the workers using poolboy:checkout(mg_pool1).
To fix the code, change gen_server:start_link({local, ?SERVER}, ?MODULE, Args, []) to gen_server:start_link(?MODULE, Args, []). Then it will not be registered with a name.