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

Bekes, Andras G <>
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'; 
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: <mailto:> [mailto:] On Behalf Of Zandra Hird
Sent: Wednesday, February 18, 2015 3:24 PM
To: <mailto:>
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
Morgan Stanley | ISG Technology
Lechner Odon fasor 8 | Floor 06
Budapest, 1095
Phone: +36 1 881-3975
<mailto:>


________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies; do not disclose, use or act upon the information; and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.



_______________________________________________

erlang-questions mailing list

<mailto:>

http://erlang.org/mailman/listinfo/erlang-questions



________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies; do not disclose, use or act upon the information; and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
-------------- 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