[erlang-questions] {error,closed} vs. {error,econnreset}

Bekes, Andras G Andras.Bekes@REDACTED
Fri May 1 14:11:08 CEST 2015


I forgot to mention that I was using Erlang R16B03 (erts-5.10.4) and the OS process indeed received the ECONNRESET result, according to strace.

From: Bekes, Andras G (ICT)
Sent: Friday, May 01, 2015 1:53 PM
To: 'Zandra Hird'; erlang-questions@REDACTED
Subject: RE: [erlang-questions] {error,closed} vs. {error,econnreset}

Hi Zandra,

I tried tracing on all prim_inet module function calls, plus gen_tcp plus all messages, but did not find the econnreset or resv0 strings anywhere.

I used the following code:
dbg:tpl(prim_inet,[{'_',[],[{exception_trace}]}]).
dbg:tpl(gen_tcp,[{'_',[],[{exception_trace}]}]).
f(F),F=fun()->dbg:p(self(),[call,m,sos,sol]), {ok,Socket}=TCP_CONNECT("localhost",12345),
ok=gen_tcp:send(Socket,<<"a:b",0>>),io:format("~p:~p\n",[self(),gen_tcp:recv(Socket,100)]) end.

Please see the trace in the attached file. Do you have suggestions on what else shall I trace?

Thanks,
   Andras

From: erlang-questions-bounces@REDACTED<mailto:erlang-questions-bounces@REDACTED> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Zandra Hird
Sent: Wednesday, February 18, 2015 3:24 PM
To: erlang-questions@REDACTED<mailto:erlang-questions@REDACTED>
Subject: Re: [erlang-questions] {error,closed} vs. {error,econnreset}

Hi,

yes this sounds confusing. We looked into it a little bit but couldn't find the reason for it right away. Have you tried tracing the resv0 in prim_inet? It might give you some more information about why this happens. We can look into it some more too when we get the time, and if you don't find out more before that :)

/ Zandra
On 2015-02-10 14:39, Bekes, Andras G wrote:
Hi All,

Looks like I have a problem with the erroneous result of gen_tcp:recv/2, as it returns {error,closed} instead of my expectation of {error,econnreset}.

I can reproduce my problem by:

1, starting a server application and forcing it into a busy state when it is listening but not accepting connections

2,starting 1000 clients (in Erlang) that connect to the server, filling the TCP listen backlog of the server.
When the backlog is filled and after some time (~2 minutes), the Erlang connections return {error,closed}.
This is what I do in Erlang:
fun()->{ok,Socket}= TCPCONNECT(HOST,PORT),
       ok=gen_tcp:send(Socket,<<"SOMEDATA...">>),
       io:format("~p:~p\n",[self(),gen_tcp:recv(Socket,100)])
end.
spawn this 1000 times.

3, a native client of the service however tells me that the connection was reset by peer.
According to strace, it executes a recvfrom which returns ECONNRESET:
recvfrom(...) = -1 ECONNRESET (Connection reset by peer)
I also straced the Erlang beam process and it indeed gets an ECONNRESET result for the recvfrom call, but the Erlang return value is {error,closed}.

Unfortunately it looks like I really need to separate these two results.

I also tried gen_tcp in active mode, but no difference, the result is {error,closed} instead of {error,econnreset}.

Can someone explain why the econnreset error is masked? Is there any way I can separate the two kinds of events?

Thanks,
Andras G. Bekes
_______________________________________________

erlang-questions mailing list

erlang-questions@REDACTED<mailto:erlang-questions@REDACTED>

http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150501/e6d0d149/attachment.htm>


More information about the erlang-questions mailing list