RESOLVED - Guru Meditation 503 - Magento Admin Generate & Download PDF

7 posts / 0 new
Last post
RESOLVED - Guru Meditation 503 - Magento Admin Generate & Download PDF


Getting a Guru Meditation 503 error when trying to generate and download pdf documents in magento. So far set the following in our VCL and /etc/default/varnish which has made no diffrence.

.connect_timeout = 18000s;
.first_byte_timeout = 18000s;
.between_bytes_timeout = 18000s;

-p http_max_hdr=128

The page load time to produce the PDF when using Apache directly without Varnish is < 3s.

The varnishlog output for the error is as follows -

15 ObjHeader c Content-Length: 53197
15 ObjHeader c Content-Disposition: attachment; filename="invoice2012-04-23_10-54-03.pdf"
15 ObjHeader c Last-Modified: Mon, 23 Apr 2012 09:54:03 +0000
15 ObjHeader c Content-Encoding: gzip
15 ObjHeader c Vary: Accept-Encoding
15 ObjHeader c Content-Type: application/pdf
15 ObjHeader c X-Purge-URL: /index.php/admin/sales_order/pdfinvoices/key/afbf1692574cab8f10cad5b1dfa17439/
15 ObjHeader c X-Purge-Host:
15 FetchError c straight read_error: 0 0 (Remote closed connection)
15 Gzip c u F - 47485 53197 80 379800 379810
15 VCL_call c error deliver
15 VCL_call c deliver deliver
15 TxProtocol c HTTP/1.1
15 TxStatus c 503
15 TxResponse c Service Unavailable
15 TxHeader c Server: Varnish
15 TxHeader c Content-Type: text/html; charset=utf-8
15 TxHeader c Retry-After: 5
15 TxHeader c Content-Length: 419
15 TxHeader c Accept-Ranges: bytes
15 TxHeader c Date: Mon, 23 Apr 2012 09:54:18 GMT
15 TxHeader c Connection: close
15 Length c 419
15 ReqEnd c 1895039024 1335174841.157484055 1335174858.645797968 0.000069141 17.488263845 0.000050068

Many Thanks in advance for any assistance.


Just incase anyone has the same or a similar problem with specific file types or URL's I managed to resolve it by putting the following in our default.vcl



if (req.url ~ "pdf") { set req.http.connection = "close"; return (pipe); }


Replace "pdf" with a string from the URL you are having issues with, obviously in our case this was "pdf".




I'm having a similar problem but with static PDF files from the backend. On certain browsers (I think those with the Adobe Reader plugin) sometimes the user gets an error saying the PDF looks corrupted. I think it might be when the file is not already in cache and Varnish fetches it from the backend. The delay before it responds to the client might trigger some timeout. 

@chritiansayers: This change you made was inside vcl_pipe ?


I had similar problem, but the solution above didn't help for serving PDF invoice. It is probalby good only for static PDF files.

I came with this and it works by passing invoice PDF prints directly to Apache, as they are alwas dynamic an not need to be cached:

if ( req.url ~ ".*/admin/sales_order_invoice/print/.*" ) {
  set req.http.connection = "close";



Thanks Vladan, Could you be more specific as to where your code is to be inserted (sorry Varnish nubee). My own code would look like the following:


if ( req.url ~ ".*/index.php/poacher/sales_order/pdfinvoices/.*" ) {

  set req.http.connection = "close";




if ( req.url ~ ".*/index.php/poacher/sales_order_invoice/print/.*" ) {

  set req.http.connection = "close";




I wonder if this is in the correct format? Any help would be greatly appreciated!


How large are Your files... Check varnish log for errors becouse since 3.0.0 version varnish has a bug:

Upgrade to 3.0.3 fix this bug.

Temporary fix is to increase nuke_limit (10 by default - in my case 1000 fix it).


Same issue with a clients Magento install.  I was able to work around this by streaming the response of all POST requests.  They aren't cached anyway, so no point in pulling the whole thing into varnish first.  The errors are still in the logs oddly enough(straight insufficient bytes,stream error?) but the PDF files downloaded properly...