[erlang-questions] tcp connections dropped in gen_server

Ladislav Lenart lenartlad@REDACTED
Thu Sep 8 10:04:29 CEST 2011


On 7.9.2011 19:33, Reynaldo Baquerizo wrote:
>>>> It makes very little sense to restart these processes (to me), because
>>>> the TCP connection will die as well. The external client can reconnect
>>>> and start anew. Or am I missing something?
>>> Indeed, the client will reconnect. But I think I found the problem. The
>>> process that is listening for new connections in gen_tcp:accept/1 dies
>>> at some point, all other processes with established connections are fine
>>> but eventually crash (cause of bad input), no further reconnections
>>> will be possible.
>> I see. Can you provide us with the exact cause of it (i.e. what
>> gen_tcp:accept/1 returned)? It seems to me that under normal
>> operation (if the accept was successful at least once before),
>> there should be no problem of this kind...
> Achh,, found it (think so)
> I've hit the ERL_MAX_PORTS limit


> For further reference I am running Erlang on a Windows Server 2008.
> Besides setting ERL_MAX_PORTS to a higher number, any other suggestion?
> I have already found this thread
> http://erlang.2086793.n4.nabble.com/error-emfile-on-windows-td3064840.html
>   in case anyone else find it useful.

No, I am afraid. Maybe someone else can help...

>>> How can I isolate the listening process? or reestructure to restart it
>>> if it crashes?
>> You need to restructure the processes then:
>>     port (service) supervisor - one_to_one
>>         acceptor - worker
>>         session supervisor - simple_one_to_one
>>             connection - worker
> I don't want to augment the complexity, I will tune ERL_MAX_PORTS and
> handle the exhaustion with a case clause to avoid terminating the
> process.

One question, how do you plan to handle the exhaustion of the ports,
i.e. what will you do in the newly added case clause?

> Thanks for the lengthy explanation

You're welcome.

Ladislav Lenart

More information about the erlang-questions mailing list