Skip to content

Commit

Permalink
Handle ssl listen error on unsolicited server
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwinchester authored and mattludwigs committed Dec 19, 2019
1 parent d2219a8 commit cd41f43
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/grizzly/unsolicited_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Grizzly.UnsolicitedServer do
:listen,
%State{config: %Config{ip_address: ip_address, ip_version: ip_version}} = state
) do
case :ssl.listen(41230, opts(ip_address, ip_version)) do
case ssl_listen(ip_address, ip_version) do
{:ok, listensocket} ->
_ = Logger.info("[GRIZZLY]: unsolicited server waiting for connections")
start_accepting_sockets(listensocket)
Expand All @@ -43,6 +43,14 @@ defmodule Grizzly.UnsolicitedServer do
end
end

def ssl_listen(ip_address, ip_version) do
try do
:ssl.listen(41230, opts(ip_address, ip_version))
rescue
error -> error
end
end

def start_accepting_sockets(listensocket) do
Enum.each(1..10, fn _ -> SocketSupervisor.start_socket(listensocket) end)
end
Expand Down

0 comments on commit cd41f43

Please sign in to comment.