meh/reagent

Reagent.Listener terminate by msg {#Reference<.....>, :badarg}

Opened this issue · 0 comments

Linux ubuntu-4vcpu-8gb 4.4.0-130-generic
Elixir 1.5.3
Erlang/OTP 20

Cauldron 0.1.10
Reagent 0.1.14
Socket 0.3.12

the :badarg occurs when the Reagent.Listener try to close connection in its
handle_info({ :DOWN, ref, _type, _object, _info }, self). because the module doesn't handle this :badarg msg, so the Reagent.Listener crashed. and i try to print the call stack when error happens and got this

{#Reference<.....>, :badarg}
[{:erlang, :port_close, [#Port<0.140215>], []}, {:prim_inet, :close_port, 1, []}, {:inet, :close, 1, [file: 'inet.erl', line: 164]}, {Reagent.Listener, :handle_info, 2, [file: 'deps/reagent/lib/reagent/listener.ex', line: 216]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 616]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 686]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]

i don't know why, it is a port but badarg returns when to close it. and at first i try to use a Supervisor to start the Cauldron(yeah, actually errors happened when i handle lots connections in Caruldron http server)

 Supervisor.start_link(
       [{Reagent.Listener, [
           module: Cauldron,
           env: [callback: Servlet],
           options: [backlog: 1024, recv: [buffer: 16 * 1024]],
           port: ***
       ]}],
       [strategy: :one_for_one, max_restarts: 100_000, max_seconds: 5]
     )  

but seems its not a good way, doesn't fix the error and lots restart slow down the server response. so now i have to add a handle_info in Reagent.Listener, any way it works for me but i really want to know how to fix that(or how to get the reason), thank you!