REquest line too Large (6242 > 4094)

I am trying to print a base64 string but when print preview is opened it gives me this error:

REquest line too Large (6242 > 4094)

Without a traceback what do you expect?

1 Like

Sorry for the late reply. I did not notice the message.

What I am trying to do, is generate a pdf for printing.

I get the pdf data, generate a base64 string and then generate pdf in front end.

This is a part of my code in backend:

binary_obj = xmlrpclib.Binary(open(completeName).read())
b64 = base64.b64encode(bytes(binary_obj))
return b64

where completeName is the pdf path in backend. I generate base64 string.

And in front end, this is the code:

let printBlob = exports.printBlob = function printBlob(src) {
    if (typeof window === 'undefined') {
        throw new Error('You cannot print url without defined window.');
    }
    let iframeId = 'printf';
    let iframe = document.getElementById(iframeId);
    if (!iframe) {
        iframe = document.createElement('iframe');
        iframe.setAttribute('id', iframeId);
        iframe.setAttribute('style', 'position:absolute;left:-9999px');
        document.body.append(iframe);
    }
    iframe.setAttribute('src', src);
    iframe.addEventListener('load', function () {
        iframe.contentWindow.focus();
        iframe.contentWindow.print();
        let infanticide = function infanticide() {
            iframe.parentElement.removeChild(iframe);
            window.removeEventListener('focus', infanticide);
        };
        window.addEventListener('focus', infanticide);
    });
};

I got the code JS from StackOverflow.

It opens a printing windows on Chrome but is says Bad Request. Request Line too large.

This is most likely something from gunicorn.

in supervisor, set --limit-request-line 0 (or some other value you desire) to increase this limit

http://docs.gunicorn.org/en/latest/settings.html?highlight=limit_request_line

gunicorn or superviror ? I found the supervisor.conf file but where shuold i put it?

Any resolution?

edit the supervisor.conf in your erpnext config folder , find the line that has gunicorn text, then edit that command line by inserting the line :

--limit-request-line 0

in my supervisor conf file , it could be like this:

... 
... 
command=/opt/bench/erpnext2/env/bin/gunicorn -b 127.0.0.1:8001 -w 9 -t 120 --limit-request-line 0  frappe.app:application --preload
...
...
1 Like

Thanks , This works for me