<div dir="ltr"><span style="font-size:12.8px">I've been developing this NodeJS plugin, it implements HTTPS server and now </span><span style="font-size:12.8px">client.  I was having an issue with HTTPS request getting ECONNRESET for no </span><span style="font-size:12.8px">apparent reason; so I implemented my own request, and ran into the same sort </span><span style="font-size:12.8px">of issue.  What I was requesting was some .js files from the server, and </span><span style="font-size:12.8px">apparently my most recent changes to those files made them larger than some </span><span style="font-size:12.8px">magic number greater than 4096 but less than 6561.  The server was sending </span><span style="font-size:12.8px">using OpenSSL (statically linked in the NodeJS executable) on CentOS, and it </span><span style="font-size:12.8px">was sending the full length of the file as one buffer.  I'm using memory BIO </span><span style="font-size:12.8px">to interact with the SSL object; The buffer was transmitted as one block. </span><span style="font-size:12.8px">With my own client, (where I could add debugging) was receiving the full </span><span style="font-size:12.8px">count of bytes from the server but in two blocks, the first 4096 and the </span><span style="font-size:12.8px">second 2472(something like that).  Because my network read buffer was only </span><span style="font-size:12.8px">4096.... So the first read was short, and caused SSL_read to fail, which I </span><span style="font-size:12.8px">had initially treated as a failure and terminated my connection.  I then</span><br style="font-size:12.8px"><span style="font-size:12.8px">found I could (almost) check using SSL_pending before getting an error </span><span style="font-size:12.8px">(really I ended up doing SSL_read( ssl, NULL, 0 ) and then SSL_pending(ssl)</span><br style="font-size:12.8px"><span style="font-size:12.8px">).  But after receiving the full count of bytes and having nothing else to </span><span style="font-size:12.8px">receive, the message never completed (read return -1, and error 2, pending</span><br style="font-size:12.8px"><span style="font-size:12.8px">returned 0 ). </span><span style="font-size:12.8px">I manually broke up the transmission to 4356 (3*1452 -29) bytes so it ends </span><span style="font-size:12.8px">up sending in 3 full tcp buffer units, and that works.  (it's http protocol </span><span style="font-size:12.8px">so it's got higher level gathering for the fragments).  It also works if I </span><span style="font-size:12.8px">revert to using the NodeJS HTTPS request object instead of my own.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">So - how do I know what the maximum amount of data I can send is?</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Node TLS object (on which HTTPS is based) has </span><span style="font-size:12.8px">tlsSocket.setMaxSendFragment(</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">size)(which defaults to 16384)  but that's </span><span style="font-size:12.8px">about sending, not receiving, so I really have no idea how big the receive </span><span style="font-size:12.8px">buffer is actually.... (same as SSL send fragment default)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">I did find </span><a href="https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_split_send_fragment.html" rel="noreferrer" target="_blank" style="font-size:12.8px">https://www.openssl.org/docs/<wbr>man1.1.0/ssl/SSL_CTX_set_<wbr>split_send_fragment.html</a> <span style="font-size:12.8px">but there's no get_for fragment size I could find.  (this would be on the </span><span style="font-size:12.8px">server side that I need to know how much I can send).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">how do I set how big of a fragment I can receive?  Like what if I tried to </span><span style="font-size:12.8px">send 100's of Meg as a single fragment?   (I guess it should auto fragment to like 16k) </span><div><span style="font-size:12.8px"><br></span><div><span style="font-size:12.8px">I guess there (will be) </span><span style="font-size:12.8px">SSL_CTX_set_default_read_</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">buffer_len() (1.1.0)</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">(node's open ssl version)</span><br style="font-size:12.8px"><span style="font-size:12.8px">#  define OPENSSL_VERSION_TEXT    "OpenSSL 1.0.2l  25 May 2017"</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">I guess read should default to something like SSL3_RT_MAX_PLAIN_LENGTH + </span><span style="font-size:12.8px">SSL3_RT_MAX_ENCRYPTED_OVERHEAD (16704)  ?  I wonder why it doesn't.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><br style="font-size:12.8px"></div></div></div>