-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Hi,
I'm following this book chapter by chapter, and so far I have enjoyed it a lot!. However, now I'm struggling with the get_count function. It seems that is not possible to call tr_server:get_count(). from telnet because this will cause a deadlock on the server side:
telnet localhost 1055
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
tr_server:get_count().
{timeout,{gen_server,call,[tr_server,get_count]}}
Connection closed by foreign host.
This makes sense to me, because handle_info is performing a call to tr_server:get_count() that performs a sync call to the server.
The thing that I don't understand is why when I'm calling get_count from the erlang console I get the same error:
13> tr_server:start_link(1055).
{ok,<0.76.0>}
14> tr_server:get_count().
** exception exit: {timeout,{gen_server,call,[tr_server,get_count]}}
in function gen_server:call/2 (gen_server.erl, line 180)
The thing that makes more sad is the fact of why we define a get_count function if we cannot use it at all.
It would be great if you could help to understand this issue. I'm using the exact file from the repo, so I'm not introducing any noise.
Thanks,