title: Unable to upload zip files occasionally
body: <p>Tomcat server runs in US. I am connecting to the server from China using Java's HTTPURLConnection. Please see the code snippet used in client side and the https connector configuration in the tomcat server side below. </p>
  
  <pre><code>&lt;!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --&gt;
      &lt;Connector acceptCount="100" clientAuth="false" connectionTimeout="-1" debug="4" disableUploadTimeout="true" enableLookups="false" keystoreFile="conf/server.keystore" keystorePass="passw47d" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="443" scheme="https" secure="true" sslProtocol="TLS" useBodyEncodingForURI="true"/&gt;
  
  
      URL url=new URL(urlString);
      HttpsURLConnection connection=null;
      try
      {
          connection=(HttpsURLConnection)url.openConnection();
          connection.setDoOutput(true);
          connection.setDoInput(true);
          connection.setRequestMethod("POST");
          connection.setRequestProperty("Content-Type", "application/zip");
          connection.setRequestProperty("Transfer-Encoding", "chunked" );
          connection.setChunkedStreamingMode(4096);
          connection.connect();
          sout=new BufferedOutputStream(connection.getOutputStream());
          break;
      }
      catch(FileNotFoundException exc)
      {
          throw exc;
      }
      bis=new FileInputStream(zipfile);
  
      int i;    
      byte bytes[]=new byte[4096]; 
      while((i=bis.read(bytes))!=-1)
      {
          sout.write(bytes,0,i);
          sout.flush();
      }  
      sout.close();
      bis.close();
  </code></pre>
  
  <p>The client uploads the zip files successfully most of the times. Occasionally the client program throws the following exception. </p>
  
  <pre><code>java.io.IOException: Error writing request body to server
  at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(Unknown Source)
  at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(Unknown Source)
  at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
  at java.io.BufferedOutputStream.flush(Unknown Source)
  at SendFiles.sendNowThruHttp(SendFiles.java:449)
  at SendFiles.run(SendFiles.java:180)
  </code></pre>
  
  <p>What could be the problem?</p>