Skip to content
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

FunctionClauseError for Socket.handle_info(:ssl_error) #44

Open
Sinc63 opened this issue Nov 24, 2021 · 1 comment
Open

FunctionClauseError for Socket.handle_info(:ssl_error) #44

Sinc63 opened this issue Nov 24, 2021 · 1 comment

Comments

@Sinc63
Copy link

Sinc63 commented Nov 24, 2021

Environment

Using version 0.4.4

  • Elixir & Erlang/OTP versions (elixir --version):
    Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.10.3 (compiled with Erlang/OTP 23)

  • Operating system:

Current behavior

Include code samples, errors and stacktraces if appropriate.
[error] function=error_info/7 line=934 module=gen_server GenServer #PID<0.931.0> terminating
** (FunctionClauseError) no function clause matching in Kadabra.Socket.handle_info/2
(kadabra 0.4.4) lib/socket.ex:170: Kadabra.Socket.handle_info({:ssl_error, {:sslsocket, {:gen_tcp, #Port<0.57>, :tls_connection, :undefined}, [#PID<0.933.0>, #PID<0.932.0>]}, {:tls_alert, {:certificate_expired, 'TLS client: In state connection received SERVER ALERT: Fatal - Certificate Expired\n '}}}, %Kadabra.Socket{active_user: #PID<0.928.0>, buffer: "", socket: {:sslsocket, {:gen_tcp, #Port<0.57>, :tls_connection, :undefined}, [#PID<0.933.0>, #PID<0.932.0>]}})
(stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
(stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:ssl_error, {:sslsocket, {:gen_tcp, #Port<0.57>, :tls_connection, :undefined}, [#PID<0.933.0>, #PID<0.932.0>]}, {:tls_alert, {:certificate_expired, 'TLS client: In state connection received SERVER ALERT: Fatal - Certificate Expired\n '}}}#012State: %Kadabra.Socket{active_user: #PID<0.928.0>, buffer: "", socket: {:sslsocket, {:gen_tcp, #Port<0.57>, :tls_connection, :undefined}, [#PID<0.933.0>, #PID<0.932.0>]}}

Expected behavior

A result as expected as :ssl_error should be explicitly handled.

@Sinc63
Copy link
Author

Sinc63 commented Nov 25, 2021

A possible solution would be to add a function clause along the lines of:

  def handle_info({:ssl_error, _, reason}, state) do
    Kernel.send(state.active_user, {:closed, self()})
    {:noreply, %{state | socket: nil}}
  end

I initially found a warning quite helpful in my system because it gave the only explicit indication that my Apple Push Notification Service certificate was expired. The only other symptom was intermittent timeout failures. Now however with this function in place I seem to consistently get the log from tls decode with the error content, so I removed the warning from the suggested code.

I'm not sure if sending :closed is the right result, but it seems to be working for me.

Sinc63 added a commit to infinityoneframework/kadabra that referenced this issue Nov 26, 2021
add handler for error condition to avoid crash on error

Closes #codedge-llc#44
mdlkxzmcp pushed a commit to mdlkxzmcp/kadabra that referenced this issue Aug 2, 2023
add handler for error condition to avoid crash on error

Closes #codedge-llc#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant