Ciboulette

Ciboulette

Catch RabbitMQ :heartbeat_timeout

Good evening,

I am working on a escript executable in plain elixir. I’m currently using RabbitMQ with the AMQP library which is great. I’m using rabbitMQ heartbeat to handle lack of connection. When i turn down my wifi connection there is a heartbeat_timeout and this is normal ! I just want to catch this message to avoid showing this to the user in his console, but i can’t figure it out. How can i do this ? The message in the console is below:

22:02:37.681 [error] GenServer #PID<0.257.0> terminating
** (stop) :heartbeat_timeout
Last message: :heartbeat_timeout
State: {:state, :amqp_network_connection, {:state, #Port<0.9883>, "client adress -> adress:5672", 10, #PID<0.260.0>, 131072, #PID<0.256.0>, :undefined, false}, #PID<0.259.0>, {:amqp_params_network, "1v62q9wtxu2sckso", "33oga51ho8yswo0gwswg44440kwc4k4okkksgg0kks4wkkcc08", "/", 'adress.com', 5672, 0, 0, 10, :infinity, :none, [&:amqp_auth_mechanisms.plain/3, &:amqp_auth_mechanisms.amqplain/3], [], []}, 0, [{"capabilities", :table, [{"publisher_confirms", :bool, true}, {"exchange_exchange_bindings", :bool, true}, {"basic.nack", :bool, true}, {"consumer_cancel_notify", :bool, true}, {"connection.blocked", :bool, true}, {"consumer_priorities", :bool, true}, {"authentication_failure_close", :bool, true}, {"per_consumer_qos", :bool, true}]}, {"cluster_name", :longstr, "rabbit@adress-production.localdomain"}, {"copyright", :longstr, "Copyright (C) 2007-2015 Pivotal Software, Inc."}, {"information", :longstr, "Licensed under the MPL.  See http://www.rabbitmq.com/"}, {"platform", :longstr, "Erlang/OTP"}, {"product", :longstr, "RabbitMQ"}, {"version", :longstr, "3.5.7"}], :none, false}

First Post!

PatNowak

PatNowak

Did you try to use handle_info that will for sure grab this message?

def handle_info(anything, channel) do
  # do something with that
end

It should be at the bottom of your handle_info list.

Most Liked

josevalim

josevalim

Creator of Elixir

Look at the Logger.Translator mechanism, which will allow you handle cases like this.

Last Post!

josevalim

josevalim

Creator of Elixir

Here is a sample translator: https://github.com/elixir-plug/plug/blob/master/lib/plug/adapters/translator.ex

The idea is that you will be able to pattern match in certain cases and convert those to better error messages.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement