Merge pull request #2957 from emqx/upgrade_fail

Defend the ssl upgrade failure
This commit is contained in:
turtleDeng 2019-10-09 09:35:22 +08:00 committed by GitHub
commit b8cf9e14de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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]),