Handle intermittent failures

This commit is contained in:
Mike Cifelli 2024-06-05 16:40:38 -04:00
parent 2690449fa9
commit 3c3d078c4d
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
1 changed files with 10 additions and 6 deletions

View File

@ -33,12 +33,16 @@ defmodule Chronoscope.NTS.KeyEstablishmentClient do
end
defp perform_key_establishment(socket) do
:ok = @ssl.send(socket, KeyEstablishmentRequest.create())
{:ok, peercert} = @ssl.peercert(socket)
with :ok <- @ssl.send(socket, KeyEstablishmentRequest.create()),
{:ok, peercert} <- @ssl.peercert(socket) do
peercert
|> await_response()
|> tap(fn _ -> @ssl.close(socket) end)
else
e ->
@ssl.close(socket)
{:error, e}
end
end
defp await_response(peercert) do