diff --git a/lib/grizzly/unsolicited_server.ex b/lib/grizzly/unsolicited_server.ex index 70f809c7..a86a0814 100644 --- a/lib/grizzly/unsolicited_server.ex +++ b/lib/grizzly/unsolicited_server.ex @@ -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) @@ -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