<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi!<br>
<br>
If you make your client use a passive socket instead of a active
one your first test case, it will work better!<br>
<br>
I also rewrote your second version into: (which works fine for
me)<br>
<br>
-module(big2).<br>
-compile(export_all).<br>
<br>
server() -><br>
ssl:start(),<br>
CaInfo = erl_make_certs:make_cert([{key, dsa}]),<br>
{Cert, {Asn1Type, Der, _}} = erl_make_certs:make_cert([{key,
dsa}, {issuer, CaInfo}]),<br>
Key = {Asn1Type, Der},<br>
spawn(fun() -><br>
{ok, L} = ssl:listen(44444, [<br>
{cert, Cert},<br>
{key, Key},<br>
{active, false},<br>
binary <br>
]),<br>
{ok, S} = ssl:transport_accept(L),<br>
ssl:ssl_accept(S),<br>
ok = recv(S, 27),<br>
ok = recv(S, size(<< 0:800000000 >>)),<br>
ok = ssl:send(S, <<"it works!">>),<br>
ssl:shutdown(S, write),<br>
ok = recv(S, 2)<br>
end).<br>
<br>
client() -><br>
{ok, S} = ssl:connect("localhost", 44444, [{active, false},
binary]),<br>
ssl:send(S, "some data before a big body"),<br>
ssl:send(S, << 0:800000000 >> ),<br>
recv(S, 9),<br>
ssl:send(S, "ok"),<br>
ok.<br>
<br>
recv(_S, 0) -><br>
ok;<br>
recv(S, N) -><br>
{ok, Bin} = ssl:recv(S, 0, 5000),<br>
recv(S, N - size(Bin)).<br>
<br>
<br>
Regards Ingela Erlang/OTP team - Ericsson AB<br>
<br>
On 02/08/2014 07:50 PM, Loïc Hoguin wrote:<br>
</div>
<blockquote cite="mid:52F67C80.7070205@ninenines.eu" type="cite">Hello,
<br>
<br>
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.
<br>
<br>
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).
<br>
<br>
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.
<br>
<br>
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.
<br>
<br>
You need erl_make_certs from the SSL test suite for this test case
too.
<br>
<br>
Below output is for R16B02 but the issue also occurs with master
updated sometimes this week too.
<br>
<br>
% erl
<br>
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4]
[async-threads:10] [hipe] [kernel-poll:false]
<br>
<br>
Eshell V5.10.3 (abort with ^G)
<br>
1> c(erl_make_certs).
<br>
{ok,erl_make_certs}
<br>
2> c(sslbig).
<br>
{ok,sslbig}
<br>
3> "With shutdown write".
<br>
"With shutdown write"
<br>
4> sslbig:server().
<br>
<0.69.0>
<br>
5> sslbig:client().
<br>
** exception error: no match of right hand side value
{error,closed}
<br>
in function sslbig:client/0 (sslbig.erl, line 29)
<br>
6> c(sslbig).
<br>
{ok,sslbig}
<br>
7> "Without shutdown write".
<br>
"Without shutdown write"
<br>
8> sslbig:server().
<br>
<0.84.0>
<br>
9> sslbig:client().
<br>
** exception error: no match of right hand side value
{error,timeout}
<br>
in function sslbig:client/0 (sslbig.erl, line 29)
<br>
10>
<br>
<br>
Enjoy!
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-bugs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-bugs">http://erlang.org/mailman/listinfo/erlang-bugs</a>
</pre>
</blockquote>
<br>
</body>
</html>