zeromq / chumak

Pure Erlang implementation of ZeroMQ Message Transport Protocol.
Mozilla Public License 2.0
197 stars 47 forks source link

Silence :connection_error #28

Closed micahrye closed 5 years ago

micahrye commented 6 years ago

Is it possible to silence :connection_error messages?

In my case I am using Chumak via Elixir. In the application I am using a push socket, but the socket to connect to (pull) may not have bound yet etc.

When the pull socket is not bound I get a done of [{:host, 'localhost'}, {:port, 3400}, :connection_error, {:error, :econnrefused}] in the console when developing or in logs.

Example code:

socket_port = 3400
{:ok, socket} = :chumak.socket(:push, 'pushid')
:chumak.connect(socket, :tcp, 'localhost', socket_port)
micahrye commented 6 years ago

While the following does not solve this issue, it shows how others have turned off logging from a Erlang dependency. In the case of the link:

config :sasl, :sasl_error_logger :false

For an application that use SASL.

There is also this thread, but still have not found the answer, though I have learned a bit.

Probably not related but for the config :sasl I have seen the following three different configs discussed:

config :sasl, :sasl_error_logger, false
config :sasl, sasl_error_logger: false
config :sasl, sasl_error_logger: :false
drozzy commented 6 years ago

The error is generated here:

https://github.com/zeromq/chumak/blob/88cfb85ab4aa0f1b9a2a8607f16b2b433b6b9c37/src/chumak_peer.erl#L275

Is the error not correct? Regarding silencing the logs, see here: http://erlang.org/doc/man/error_logger.html#error_report-1 and http://erlang.org/doc/system_principles/error_logging.html

Let me know if this helps or not.

micahrye commented 6 years ago

I think the error is correct, but in some cases it would be nice to have a different behavior. In my case I know that the pull socket will not always be active, that is fine in this system.

Given the correct behavior of Chumak and the zmq protocol, the push socket will continue to retry. What I would like is that in the case that I know I will have one side of a socket not be present to get a single error message or a message less frequently.

This is probably not the right behavior, and me just whining :)

I did look into the links that you provided, but I was not able to get the error_logger to be silent???

Because it was bothering me, I changed aspects of the system to make sure the pull socket is up always.

If someone knows how to configure an Elixir app to silence the error_logger I would still appreciate it.

drozzy commented 6 years ago

Try erlang slack, they are very smart there:

Get invite: https://erlang-slack.herokuapp.com

Join: https://erlanger.slack.com/messages

They will also help with Elixir.

drozzy commented 5 years ago

Please let us know if you fixed the issue. I’m going to close this - reopen it if you still have a problem.