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

Fredrik Thulin <>
Wed May 28 10:01:41 CEST 2008

Marcin Maciukiewicz wrote:
> Thank both of you guys for help. So far I understand what you say, but
> I'm not sure how it may help.
> In the following code, last executed line is #14. After that VM hangs
> for 5 sec thus I don't see a reasonable place to put
> gen_server:reply/2. call.
> http://pastebin.com/f590f0e00
> I feel I need an extra push to understand. The reason why I play with
> {noreply, State} is because I want to understand how to deal with this
> case.

Which case is that?

If you want to call a gen_server and get a response from it, you call it 
using gen_server:call(...).

   For this case, the gen_server handle_call function MUST either return
   {reply, ...}, or arrange for some process (the gen_server or another,
   for example a spawned worker process) to call gen_server:reply(...)
   before the caller times out.

On the other hand, if you want to tell a gen_server that it should do 
something, but you don't care about a return value from the gen_server, 
you use gen_server:cast(...) instead. In the gen_server, you then code 
an appropriate handle_cast(...) function clause instead of a 


More information about the erlang-questions mailing list