Handle TCP errors in websockets

This commit is contained in:
Evgeny Khramtsov 2019-05-09 22:06:23 +03:00
parent e427358e08
commit 4b6f1195c6
1 changed files with 3 additions and 0 deletions

View File

@ -203,6 +203,9 @@ ws_loop(FrameInfo, Socket, WsHandleLoopPid, SocketMode) ->
{tcp_closed, _Socket} ->
?DEBUG("tcp connection was closed, exit", []),
websocket_close(Socket, WsHandleLoopPid, SocketMode, 0);
{tcp_error, Socket, Reason} ->
?DEBUG("tcp connection error: ~s", [inet:format_error(Reason)]),
websocket_close(Socket, WsHandleLoopPid, SocketMode, 0);
{'DOWN', Ref, process, WsHandleLoopPid, Reason} ->
Code = case Reason of
normal ->