从MongooseIM连接到RabbitMQ服务器

时间:2015-04-23 22:22:26

标签: erlang mongoose-im

我正在尝试从我的mongooseim服务器与rabbitmq服务器通信。为此,我首先将rabbitmq-client库(用于erlang)复制到我的apps目录,更新了我的makefile,然后重新编译了mongooseim代码。 (根据here的指示)。这样我就可以编译没有错误的代码,并且可以看到amqp_client已经从mongooseim控制台启动了。现在,当我尝试从控制台运行amqp_connection:start()时,我得到以下错误。如何解决这个问题?

(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

1 个答案:

答案 0 :(得分:1)

undef错误消息告诉我们rabbit_net模块或connection_string函数丢失,rabbit_netrabbit_common包的一部分。我猜你没有添加rabbit_common。您可以在上一个问题 - here中找到您粘贴的网站上的包裹。使用rabbit_common.ez重复这些步骤,它应该有效。