You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mo...@comcast.net on 2014/10/17 22:51:21 UTC

mod-jk reports errors when downloading files above 4 MB, but runs fine for smaller file sizes

Hi, I'm using mod-jk (v1.2.40) on CentOS Linux server to pass requests from Apache web server (v2.4.9) to GlassFish (v3.1.2) application server. I'm using a java 7 servlet (shown below) on my application server to enable a client to download a PDF file via HTTPS. 

Things work fine when this file size is less than about 4 MB. When the file is larger than 4 MB, I see the following errors in the mod_jk.log file:

[info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[error] ajp_connection_tcp_get_message::jk_ajp_common.c (1313): wrong message format 0xcad5 from ::1:8009
[error] ajp_get_reply::jk_ajp_common.c (2204): (worker1) Tomcat is down or network problems. Part of the response has already been sent to the client
[info] ajp_service::jk_ajp_common.c (2673): (worker1) sending request to tomcat failed (recoverable), because of protocol error (attempt=1)
[info] ajp_process_callback::jk_ajp_common.c (2000): Writing to client aborted or client network problems
[info] ajp_service::jk_ajp_common.c (2673): (worker1) sending request to tomcat failed (unrecoverable), because of client write error (attempt=2)
[info] jk_handler::mod_jk.c (2799): Aborting connection for worker=worker1

I'm not an expert here, and wondered if anyone could decode this to find root cause and solution. There are no errors in Apache or GlassFish log files. When I run the client Google Chrome browser (for example), it appears to download the first 4 MB and then report "network error". Other browsers behave similarly. Mod_jk appears to have the only log file reporting an error. 

Other miscellaneous thoughts: 

1. My server doesn't have a firewall limiting file size. 

2. My client router/modem doesn't limit file download size (I download much larger files often). 

3. As far as I'm aware, the Java code below doesn't restrict the file size download (can anyone confirm? perhaps mod-jk is complaining about the header or content type?). 

4. GlassFish timeout is 15 minutes, and the browser stops downloading after perhaps 10 seconds.

I'm running out of things to check. What could it be? Any help is MUCH appreciated. Thanks.


---------- Java Servlet ----------

public class GetFile extends HttpServlet {

@Override
public void init(ServletConfig config) throws ServletException {
  super.init(config);
}

protected void doPost(HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException {

String filename ="init_java";

try {

    // get user parameters
    filename = req.getParameter("fileId");  // complete path to file
    //res.setContentType("video/mp4");  //not working
    res.setContentType("application/x-download");  

    File file=new File(filename);

    if (file.exists()) {

        res.setHeader("Content-Disposition", "inline; filename=\""+filename+"\"");
        res.setHeader("Cache-Control", "cache, must-revalidate");
        //res.setHeader("Pragma", "public"); // not sure when to use
        returnFile(filename, res.getOutputStream());

    } else {
        //error handling goes here
    }     

} catch (Exception e) {
    ...
} finally {
    ... 
}
}


private static void returnFile(String filename, OutputStream out) throws FileNotFoundException, IOException {
  InputStream in = null;
  try {
      in = new BufferedInputStream(new FileInputStream(filename));
      byte[] buf = new byte[4 * 1024]; // 4K buffer
      int bytesRead;
      while ((bytesRead = in.read(buf)) != -1) {
          out.write(buf, 0, bytesRead);
      }
      out.flush();

  } finally {
      if (in != null) in.close();
  }
}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: mod-jk reports errors when downloading files above 4 MB, but runs fine for smaller file sizes

Posted by mo...@comcast.net.
Thanks so much! 

----- Original Message -----

From: "Christopher Schultz" <ch...@christopherschultz.net> 
To: "Tomcat Users List" <us...@tomcat.apache.org> 
Sent: Friday, October 17, 2014 5:01:49 PM 
Subject: Re: mod-jk reports errors when downloading files above 4 MB, but runs fine for smaller file sizes 

-----BEGIN PGP SIGNED MESSAGE----- 
Hash: SHA256 

To whom it may concern, 

On 10/17/14 4:51 PM, modjklist@comcast.net wrote: 
> Hi, I'm using mod-jk (v1.2.40) on CentOS Linux server to pass 
> requests from Apache web server (v2.4.9) to GlassFish (v3.1.2) 
> application server. I'm using a java 7 servlet (shown below) on my 
> application server to enable a client to download a PDF file via 
> HTTPS. 
> 
> Things work fine when this file size is less than about 4 MB. When 
> the file is larger than 4 MB, I see the following errors in the 
> mod_jk.log file: 
> 
> [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized [error] 
> ajp_connection_tcp_get_message::jk_ajp_common.c (1313): wrong 
> message format 0xcad5 from ::1:8009 [error] 
> ajp_get_reply::jk_ajp_common.c (2204): (worker1) Tomcat is down or 
> network problems. Part of the response has already been sent to the 
> client [info] ajp_service::jk_ajp_common.c (2673): (worker1) 
> sending request to tomcat failed (recoverable), because of protocol 
> error (attempt=1) [info] ajp_process_callback::jk_ajp_common.c 
> (2000): Writing to client aborted or client network problems [info] 
> ajp_service::jk_ajp_common.c (2673): (worker1) sending request to 
> tomcat failed (unrecoverable), because of client write error 
> (attempt=2) [info] jk_handler::mod_jk.c (2799): Aborting connection 
> for worker=worker1 
> 
> I'm not an expert here, and wondered if anyone could decode this to 
> find root cause and solution. There are no errors in Apache or 
> GlassFish log files. When I run the client Google Chrome browser 
> (for example), it appears to download the first 4 MB and then 
> report "network error". Other browsers behave similarly. Mod_jk 
> appears to have the only log file reporting an error. 
> 
> Other miscellaneous thoughts: 
> 
> 1. My server doesn't have a firewall limiting file size. 
> 
> 2. My client router/modem doesn't limit file download size (I 
> download much larger files often). 
> 
> 3. As far as I'm aware, the Java code below doesn't restrict the 
> file size download (can anyone confirm? perhaps mod-jk is 
> complaining about the header or content type?). 
> 
> 4. GlassFish timeout is 15 minutes, and the browser stops 
> downloading after perhaps 10 seconds. 
> 
> I'm running out of things to check. What could it be? Any help is 
> MUCH appreciated. Thanks. 

Looks like it's an old GlassFish bug: 

https://java.net/jira/browse/GLASSFISH-18446 

and 

http://stackoverflow.com/questions/9770529/glassfish-jk-large-file-strange-response 

Funny how Googling for "mod_jk message format 0xcad5" can find exactly 
what you were looking for. 

- -chris 
-----BEGIN PGP SIGNATURE----- 
Version: GnuPG v1 
Comment: GPGTools - http://gpgtools.org 

iQIcBAEBCAAGBQJUQa3tAAoJEBzwKT+lPKRYXL0P/1r+mj6taEZHCbn1ZpSCMHJ3 
9C/ByrbV6mtbO5AQUSeJ+FJuLMoF9g02A2CjfTAXoiTzb8Q8yUSW/myGPouUsHtV 
BoexlvjCAYYrGzNybM4f6A4vQ76kq7rEXt0o8zj2V4LOHHB5pHoKsU53e2a4re+a 
/1EL0ZyVgkeZOa09vNdh0bRa15zlf3JCG5u+mKa+6H2BdSHJCz4wbv8NV74w/Jc4 
2E8j46se5Jx+pa2lhX1D2tHrcbtq3feUijELrMJcKQq0/Lujy+N7nZP/udQncdvB 
KrvSn1T9LdqYFr0QS9LuxS/6bEb36CMUifRCXjaqBiVctBAw7zxdOql0FOKZRH95 
mNtajRhpJJp7dPzLMes0uowcCqa5M957r64ab0/KOcNfLyhwmmUVTiFSFZ3FWoOP 
azsu5IDFO6HVK46MxHWWqoJOdE2bEFcYCSwpOcImDwCxHGckDtZYlY8lTPPQr/jx 
2s/M0lvYCYwxKGwF9bqpREuPrRCH+YLIDUxdwoloy3o75k8GzR2QPxvEOnzqEose 
rMzWcDpnS09MSK5vHJ7EzFgMa8S/ohqK9dYTASNe2rpJ1QXZSgpe39JH2snhuk7j 
wwX19WrHrADL71qz8Ekg2mNnyyaHxJF5yU1kFgB0eTF4makZbheaP0CuArV+EWiJ 
cS3TsRD9t6kRvz6FDsP7 
=+0h4 
-----END PGP SIGNATURE----- 

--------------------------------------------------------------------- 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org 
For additional commands, e-mail: users-help@tomcat.apache.org 



Re: mod-jk reports errors when downloading files above 4 MB, but runs fine for smaller file sizes

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

To whom it may concern,

On 10/17/14 4:51 PM, modjklist@comcast.net wrote:
> Hi, I'm using mod-jk (v1.2.40) on CentOS Linux server to pass
> requests from Apache web server (v2.4.9) to GlassFish (v3.1.2)
> application server. I'm using a java 7 servlet (shown below) on my
> application server to enable a client to download a PDF file via
> HTTPS.
> 
> Things work fine when this file size is less than about 4 MB. When
> the file is larger than 4 MB, I see the following errors in the
> mod_jk.log file:
> 
> [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized [error]
> ajp_connection_tcp_get_message::jk_ajp_common.c (1313): wrong
> message format 0xcad5 from ::1:8009 [error]
> ajp_get_reply::jk_ajp_common.c (2204): (worker1) Tomcat is down or
> network problems. Part of the response has already been sent to the
> client [info] ajp_service::jk_ajp_common.c (2673): (worker1)
> sending request to tomcat failed (recoverable), because of protocol
> error (attempt=1) [info] ajp_process_callback::jk_ajp_common.c
> (2000): Writing to client aborted or client network problems [info]
> ajp_service::jk_ajp_common.c (2673): (worker1) sending request to
> tomcat failed (unrecoverable), because of client write error
> (attempt=2) [info] jk_handler::mod_jk.c (2799): Aborting connection
> for worker=worker1
> 
> I'm not an expert here, and wondered if anyone could decode this to
> find root cause and solution. There are no errors in Apache or
> GlassFish log files. When I run the client Google Chrome browser
> (for example), it appears to download the first 4 MB and then
> report "network error". Other browsers behave similarly. Mod_jk
> appears to have the only log file reporting an error.
> 
> Other miscellaneous thoughts:
> 
> 1. My server doesn't have a firewall limiting file size.
> 
> 2. My client router/modem doesn't limit file download size (I
> download much larger files often).
> 
> 3. As far as I'm aware, the Java code below doesn't restrict the
> file size download (can anyone confirm? perhaps mod-jk is
> complaining about the header or content type?).
> 
> 4. GlassFish timeout is 15 minutes, and the browser stops
> downloading after perhaps 10 seconds.
> 
> I'm running out of things to check. What could it be? Any help is
> MUCH appreciated. Thanks.

Looks like it's an old GlassFish bug:

https://java.net/jira/browse/GLASSFISH-18446

and

http://stackoverflow.com/questions/9770529/glassfish-jk-large-file-strange-response

Funny how Googling for "mod_jk message format 0xcad5" can find exactly
what you were looking for.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUQa3tAAoJEBzwKT+lPKRYXL0P/1r+mj6taEZHCbn1ZpSCMHJ3
9C/ByrbV6mtbO5AQUSeJ+FJuLMoF9g02A2CjfTAXoiTzb8Q8yUSW/myGPouUsHtV
BoexlvjCAYYrGzNybM4f6A4vQ76kq7rEXt0o8zj2V4LOHHB5pHoKsU53e2a4re+a
/1EL0ZyVgkeZOa09vNdh0bRa15zlf3JCG5u+mKa+6H2BdSHJCz4wbv8NV74w/Jc4
2E8j46se5Jx+pa2lhX1D2tHrcbtq3feUijELrMJcKQq0/Lujy+N7nZP/udQncdvB
KrvSn1T9LdqYFr0QS9LuxS/6bEb36CMUifRCXjaqBiVctBAw7zxdOql0FOKZRH95
mNtajRhpJJp7dPzLMes0uowcCqa5M957r64ab0/KOcNfLyhwmmUVTiFSFZ3FWoOP
azsu5IDFO6HVK46MxHWWqoJOdE2bEFcYCSwpOcImDwCxHGckDtZYlY8lTPPQr/jx
2s/M0lvYCYwxKGwF9bqpREuPrRCH+YLIDUxdwoloy3o75k8GzR2QPxvEOnzqEose
rMzWcDpnS09MSK5vHJ7EzFgMa8S/ohqK9dYTASNe2rpJ1QXZSgpe39JH2snhuk7j
wwX19WrHrADL71qz8Ekg2mNnyyaHxJF5yU1kFgB0eTF4makZbheaP0CuArV+EWiJ
cS3TsRD9t6kRvz6FDsP7
=+0h4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org