-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple errors cause backend to exit #5
Comments
I would suggest adding Additionally, this backend doesn't handle the Here's an (untested) diff: diff --git a/src/lager_logstash_backend.erl b/src/lager_logstash_backend.erl
index 059317a..57a79ad 100644
--- a/src/lager_logstash_backend.erl
+++ b/src/lager_logstash_backend.erl
@@ -72,7 +72,8 @@ arg(Name, Args, Default) ->
end.
connect({tcp, Host, Port}) ->
- Opts = [binary, {active, false}, {keepalive, true}],
+ Opts = [binary, {active, false}, {keepalive, true},
+ {send_timeout, 500}, {send_timeout_close, true}],
case gen_tcp:connect(Host, Port, Opts) of
{ok, Socket} -> Socket;
{error, _} -> undefined
@@ -128,6 +129,10 @@ send_log(Payload, #state{output = {udp, Host, Port}, handle = Socket}) ->
send_log(Payload, #state{output = {file, _}, handle = Fd}) ->
ok = file:write(Fd, Payload).
+handle_info({tcp_closed, Socket}, #state{handle = Socket}) ->
+ {error, tcp_closed};
+handle_info({tcp_error, Socket, Reason}, #state{handle = Socket}) ->
+ {error, {tcp_error, Reason}};
handle_info(_Info, State) ->
{ok, State}. Lager will reinitialize the handler if it crashes like this, rather than hanging on a dead TCP connection where the keepalive timeout has not fired yet. |
Thanks a lot, @Vagabond! We will try patching as you suggested and create a PR or a fork if it works. |
Short version of the story is that we are using RabbitMQ server and from time to time it loses all connections to all clients and these events accompanied with exceptions that have references to lager_logstash_backend.
I have evidences of different exceptions all but all of them seem to cause exit of logstash backend.
or
We are using It is lager-3.5.1, jsx-2.7.0 and lager_logstash-0.1.3
Raised it with RabbitMQ (https://groups.google.com/forum/#!topic/rabbitmq-users/dK7r10t9jYI) because it does not feel right that any issue with logging subsystem should have such a big impact on normal operations.
Please see the lager issue I raised with logstash - erlang-lager/lager#423 - there is a very interesting discussion there.
The text was updated successfully, but these errors were encountered: