Skip to content

Commit

Permalink
Handle tcp_error so that the client won't crash and will attempt reco…
Browse files Browse the repository at this point in the history
…nnect
  • Loading branch information
Ransom Richardson committed Jan 25, 2013
1 parent 4cf18a5 commit 6b10992
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/eredis_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ handle_info({tcp, _Socket, Bs}, State) ->
inet:setopts(State#state.socket, [{active, once}]),
{noreply, handle_response(Bs, State)};

handle_info({tcp_error, _Socket, _Reason}, State) ->
%% This will be followed by a close
{noreply, State};

%% Socket got closed, for example by Redis terminating idle
%% clients. If desired, spawn of a new process which will try to reconnect and
%% notify us when Redis is ready. In the meantime, we can respond with
Expand Down
4 changes: 4 additions & 0 deletions src/eredis_sub_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ handle_info({tcp, _Socket, Bs}, State) ->
{noreply, NewState}
end;

handle_info({tcp_error, _Socket, _Reason}, State) ->
%% This will be followed by a close
{noreply, State};

%% Socket got closed, for example by Redis terminating idle
%% clients. If desired, spawn of a new process which will try to reconnect and
%% notify us when Redis is ready. In the meantime, we can respond with
Expand Down

0 comments on commit 6b10992

Please sign in to comment.