[erlang-bugs] SSL fails at sending a short message while receiving a big one
Loïc Hoguin
essen@REDACTED
Sat Feb 8 19:50:40 CET 2014
Hello,
While investigating a solution for TCP linger issues with Cowboy, I was
surprised when I saw that the solution that worked perfectly well for
TCP didn't for SSL.
It *may* be related to what fails in my other "SSL socket gets closed
abruptly" thread, as both cases send large data. However that other
thread is a little more crazy (as sending any non-200 response does work
there, while in this case I never got any response).
Please see a test case attached. It's a simpler simulation of what may
actually happen with HTTP. First a few small packets (often one) are
sent for the headers, and then a potentially huge body. The server may
not want to receive the body, but it always needs to send a response.
Problem is, if we don't read the body, that response is never sent with SSL.
It's interesting to note that incorrect behavior occurs regardless of
the shutdown call being there. That call is used for the lingering
solution mentioned above so I tried with and without. In both cases the
response isn't received by the client. If the shutdown call is there,
the recv call will eventually say {error, closed} (it may or may not
take a while, I had both). If the shutdown call isn't there, recv will
just timeout.
You need erl_make_certs from the SSL test suite for this test case too.
Below output is for R16B02 but the issue also occurs with master updated
sometimes this week too.
% erl
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4]
[async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.3 (abort with ^G)
1> c(erl_make_certs).
{ok,erl_make_certs}
2> c(sslbig).
{ok,sslbig}
3> "With shutdown write".
"With shutdown write"
4> sslbig:server().
<0.69.0>
5> sslbig:client().
** exception error: no match of right hand side value {error,closed}
in function sslbig:client/0 (sslbig.erl, line 29)
6> c(sslbig).
{ok,sslbig}
7> "Without shutdown write".
"Without shutdown write"
8> sslbig:server().
<0.84.0>
9> sslbig:client().
** exception error: no match of right hand side value {error,timeout}
in function sslbig:client/0 (sslbig.erl, line 29)
10>
Enjoy!
--
Loïc Hoguin
http://ninenines.eu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sslbig.erl
Type: text/x-erlang
Size: 774 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140208/93cf3b7f/attachment.bin>
More information about the erlang-bugs
mailing list