Skip to content

Chapter 3 - Calling get_count #4

@minostro

Description

@minostro

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions