[erlang-questions] Ho to keep-alive inactive RabbitMQ connections?

91 views
Skip to first unread message

Max Bourinov

unread,
Apr 25, 2012, 2:26:32 AM4/25/12
to erlang-questions
Hi Erlangers,

I use forked RabbitMQ client: https://github.com/jbrisbin/amqp_client

While testing it I noticed that if connection is not active for some hours it becomes closed. Interesting thing is that my Erlang app doesn't show any crashes or error messages. SASL is enabled, process that holds connection is under supervision.

Does anybody know how RabbitMQ client must be configured to keep connection alive all the time?

Best regards,
Max


Tilman Holschuh

unread,
Apr 25, 2012, 2:36:14 AM4/25/12
to Max Bourinov, erlang-questions
Hi Max,

Check out AMQP heartbeat.

Cheers
- Tilman

> _______________________________________________
> erlang-questions mailing list
> erlang-q...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Max Bourinov

unread,
Apr 25, 2012, 2:40:21 AM4/25/12
to Tilman Holschuh, erlang-questions
Hi Tilman!

I have it! It is 5 seconds in my case.

{ok, Connection} = amqp_connection:start(
        #amqp_params_network{
            host = "localhost",
            username = <<"guest">>,
            password = <<"guest">>,
            port = 5672,
            virtual_host = <<"/">>,
            heartbeat = 5
        }),


Still dropping connections...

Best regards,
Max

Bohuslav Svancara

unread,
Apr 25, 2012, 5:49:45 AM4/25/12
to erlang-q...@erlang.org
Yes. Connection is closed if a heartbeat pulse does not arrive.
You need to open connection again.
The best way (I think)  is to let module crash and its supervisor will restart (and reconnect) it.

I have "topRabbitSupervisor", which starts "rabbitConnection" module.  
rabbitConnection module opens connection and starts amqp subscribers which use this open connection.

If any of amqp subscribers lose a connection (heartbeat did not arrive) it crashes, crash propagates to topRabbitSupervisor and  topRabbitSupervisor restarts rabbitConnection which restarts all subscribers then.

It seems it works fine.

Bob

Dne 25. dubna 2012 8:40 Max Bourinov <bour...@gmail.com> napsal(a):

Max Bourinov

unread,
Apr 25, 2012, 7:16:15 AM4/25/12
to Bohuslav Svancara, erlang-q...@erlang.org
Hi Bob,

I have 1 to 1 architecture as you described. It works fine! But I cannot understand how it is possible that RabbitMQ client process loses connection WITHOUT crash? It just ABSOLUTELY silently loses connection and I know about it from RabbitMQ management interface only.

This is very strange... This is why I asked the List.

Best regards,
Max
Reply all
Reply to author
Forward
0 new messages