Defend the ssl upgrade failure

This commit is contained in:
terry-xiaoyu 2019-10-08 17:40:35 +08:00
parent ac93725f74
commit dbea5df7dc
1 changed files with 8 additions and 1 deletions

View File

@ -149,7 +149,14 @@ call(CPid, Req) ->
init({Transport, RawSocket, Options}) ->
process_flag(trap_exit, true),
{ok, Socket} = Transport:wait(RawSocket),
case Transport:wait(RawSocket) of
{ok, Socket} ->
do_init(Transport, Socket, Options);
{error, Reason} ->
?LOG(warning, "connection failed to establish: ~p", [Reason])
end.
do_init(Transport, Socket, Options) ->
{ok, Peername} = Transport:ensure_ok_or_exit(peername, [Socket]),
{ok, Sockname} = Transport:ensure_ok_or_exit(sockname, [Socket]),
Peercert = Transport:ensure_ok_or_exit(peercert, [Socket]),