title: OpenSSL SSL_ERROR_WANT_WRITE never recovers during SSL_write()
body: <p>I have two applications talking to each other over SSL.  The client is running on a windows machine, the server is a linux based application.  The client is sending a large amount of data to the server on startup.  The data is sent in ~4000byte chunks over to the server that contains 30 entries.  I have to send about 50000 entries over.  </p>
  
  <p>During that transmission the server sends a message to the client, the message size is ~4000bytes.  After that happens, the SSL_write() on the client side begins to return error of SSL_ERROR_WANT_WRITE.  The client sleeps for 10ms, and retries the SSL_write with the exact same parameters, however, the SSL_write fails infinitely.  Subsequently it aborts.  If it tries to send a new message, I get an error indicating I am not sending the same aborted message from earlier.</p>
  
  <p>error:1409F07F:SSL routines:SSL3_WRITE_PENDING: bad write retry” </p>
  
  <p>The server eventually kills the connection since it has not heard from the client for 60s and re-establishes a new one.  This is just an FYI, the real issue is how can I get SSL_write to resume.</p>
  
  <p>If the server does not send a request during the receive the problem goes away.  If I shrink the size of the request from 16K to 100 bytes the problem does not happen.</p>
  
  <p>The SSL CTX MODE is set to SSL_MODE_AUTO_RETRY and SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER.</p>
  
  <p>Does anyone have an idea what might cause a simultaneous transmission from both sides with large information can cause this failure.  What can I do to prevent it if this is a limitation other than capping the size that goes out from the server to the client.  My concern is that if the client is not sending anything the throttling I applied to avoid this issue is a waste.</p>
  
  <p>On the client side I tried to perform an SSL_read to see if I need to read during a write even though I never receive an SSL_ERROR_PENDING_READ, but the buffer is not that big anyway.  ~1000bytes in size.</p>
  
  <p>Any insight on this would be appreciated.  </p>