[erlang-questions] [gen_server] time out error when handle_call returns {noreply, State}

Chandru <>
Wed May 28 00:35:08 CEST 2008

2008/5/27 Marcin Maciukiewicz <>:
> Hi,
> This are my first steps in Erlang World. So far I'm stuck with
> gen_server:Module:handle_call/3.
%> I get time out every time when {noreply, State} is returned. Following
> are code snippets:
> * Server module: http://pastebin.com/f590f0e00
> * Test module: http://pastebin.com/f2af1806b
> * Console output: http://pastebin.com/f3b998308
> As I understand, the correct value is returned from handle_call/3. No
> problem with that. What I cannot determine is a reason for the time
> out error.

The possible return values from the handle_call/3 function are:

%% Function: handle_call/3
%% Description: Handling call messages
%% Returns: {reply, Reply, State}          |
%%          {reply, Reply, State, Timeout} |
%%          {noreply, State}               |
%%          {noreply, State, Timeout}      |
%%          {stop, Reason, Reply, State}   | (terminate/2 is called)
%%          {stop, Reason, State}            (terminate/2 is called)

If you use {noreply, State} or {noreply, State, Timeout}, then  you have to
at some point invoke gen_server:reply/2 to return a reply to the caller.
This is to allow the server process to continue doing something while
possibly waiting for something to finish.

If you want to return a reply immediately, return {reply, Reply, State} or
{reply, Reply, State, Timeout} from your handle_call/3 callback.

This page in the online documentation describes the various options pretty


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080527/6a337bbb/attachment.html>

More information about the erlang-questions mailing list