[erlang-questions] {error,closed} vs. {error,econnreset}
Zandra Hird
zandra@REDACTED
Wed Feb 18 15:23:58 CET 2015
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
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150218/d6c0af28/attachment.htm>
More information about the erlang-questions
mailing list