PhantomJS - Unable to decode

Hello,

I currently use an self hosted Version of IN with https://phantomjscloud.com/ integration (free plan with own api key).
But currently I get the error-message “[2017-07-04 20:18:55] production.ERROR: PhantomJS - Unable to decode: …” in the errorlog, when sending an invoice via email (attach invoice option is selected).

What could be the problem?

Thanks,
Michael

I’m not sure, has anything else changed?

You can either try using local PhantomJS instead or debug the code.

Hi, I had the probelm from the beginning on. First I thought the problem is the demo key, but not with the free key there should be no further problems.

How can I debug the error without installing phantomJS local?

Could there be some sort of memory/ressource limits that cause the problems?

Is your app publicly accessible?

yes!

Can you email the full error message to contact@invoiceninja.com

Also, is there an error before the one listed above.

Thanks for the log file, can you check that you have a value set for PHANTOMJS_SECRET in the .env file.

http://docs.invoiceninja.com/en/latest/configure.html#troubleshooting

Yes, the PHANTOMJS_SECRET is set, but has the default value :(.

I’m not sure I understand ‘default value’, it just needs to be a random string.

First I switched to an local version of phantomjs and real time sending, but this caused the same problem.

I now switched to queuing the mails and executing /usr/local/pd-admin2/bin/php5-5.6-cli -c /home/billisbc/php-cli.ini artisan queue:listen all 5 minutes.

I found the tipp in https://www.invoiceninja.com/forums/topic/local-phantomjs-pdf-generation/

Maybe it has something to do with https://www.invoiceninja.com/forums/topic/local-phantomjs-pdf-generation/#post-6072

I found the reason for all this problems :(:

The phantomJS Link was password protected because of the settings that clients should insert an Password.
https://xxxxxx.xxxxx.de/view/wcslfgmsyon5j1ncpsvonh8vefcg3fhe?phantomjs=true&renderType=html

After disabling the Password-Protection, everything works fine.

I don’t understand why the following does’nt worked:

PhantomJS Secret
This enables the PhantomJS request to bypass client authorization.

The link you posted doesn’t have the phantomjs_secret property set.

Yes, I saw it and understood it now.

But I don’t understand, why it is missing? Below the call to phantomjscloud. And PHANTOMJS_SECRET is set in den env File.

http://api.phantomjscloud.com/api/browser/v2/ak-4we1b-jbtvg-zrgeg-faaaw-aaxdp/?request={url:“https://xxxx.xxxx.de/view/wcslfgmsyon5j1ncpsvonh8vefcg3fhe?phantomjs=true”,renderType:“html”} {“context”:“PHP”,“user_id”:1,“account_id”:1,“user_name”:“Michael Bur am Orde”,“method”:“GET”,“url”:“https://billing.servantful.de”,“previous”:“https://xxx.xxxx.de/settings/system_settings",“user_agent”:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36”,“ip”:“93.238.86.20”,“count”:3,“is_console”:“yes”,“is_api”:“no”,“db_server”:“mysql”} []

I think I see the problem, we’ll include a fix with our next release.

I think in the phantomjscloud call die “request” URLs misses the secret key. I tried to add it but got an other error message. Please send me the link to die github-push which fixes this problem.

Here’s the fix:

https://github.com/invoiceninja/invoiceninja/commit/1d2c5f5b59ea1f15366e90581fe8067e05010560

Hi Coren,

yesterday i updated to version 3.5.0 and was not able to generate invoices via cloudphantomjs.

The error from them was:
{“message”:"Error extracting userRequest. ",“statusCode”:400}

Now I use the old url without secret and everything works fine!

Just for INfo!

Thanks for the info, I’ll look into the error.

I have a similar problem. Since i updated from 2.7.2 to 3.5.1 mails are send without invoice attached. I use local phantomjs 2.1.1
In laravel-error.log there is the message:

<em>
[2017-07-30 14:54:52] production.ERROR: PhantomJS - Unable to decode:                                  Invoice Ninja | Kostenlose Online Open-Source Rechnungsausstellung                                                                                                                                                                                                                                                               var NINJA = NINJA || {};         NINJA.fontSize = 9;         NINJA.isRegistered = false;          window.onerror = function (errorMsg, url,     lineNumber, column, error) {             if (errorMsg.indexOf('Script error.') > -1) {                 return;             }              try {                 // Use StackTraceJS to p    arse the error context                 if (error) {                     var message = error.message ? error.message : error;                     StackTrace.fromError(error).then(functio    n (result) {                         var gps = new StackTraceGPS();                         gps.findFunctionName(result[0]).then(function (result) {                             logError    (errorMsg + ': ' + JSON.stringify(result));                         });                     });                 } else {                     logError(errorMsg);                 }                      trackEvent('/error', errorMsg);             } catch (err) {             }              return false;         }          function logError(message) {             $.ajax({                     type: 'GET',                 url: 'https://rpi.it-support-ffm.de/ninja/public/log_error',                 data: 'error=' + encodeURIComponent(message) + '&url=' + encodeURIC    omponent(window.location)             });         }          // http://t4t5.github.io/sweetalert/         function sweetConfirm(success, text, title) {             title = title || "Bis    t du dir sicher?";             swal({                 //type: "warning",                 //confirmButtonColor: "#DD6B55",                 title: title,                 text: text,                     cancelButtonText: "Nein",                 confirmButtonText: "Ja",                 showCancelButton: true,                 closeOnConfirm: false,                 allowOutside    Click: true,             }).then(function() {                 success();                 swal.close();             });         }          /* Set the defaults for DataTables initialisati    on */         $.extend(true, $.fn.dataTable.defaults, {             "bSortClasses": false,             "sDom": "tl",             "sPaginationType": "bootstrap",             "bInfo": tru    e,             "oLanguage": {                 'sEmptyTable': "Es sind keine Daten vorhanden",                 'sLengthMenu': '_MENU_ Zeilen',                 'sInfo': "Zeige Eintrag _ST    ART_ bis _END_ von _TOTAL_",                 'sSearch': ''             }         });          /* This causes problems with some languages. ie, fr_CA          var appLocale = 'de';              */                  function fbq() {             // do nothing         }         ;                          window._fbq = window._fbq || [];        {"context":"PHP","user_id":1,"acc    ount_id":"1","user_name":"Invoice User 1","method":"PUT","url":"https://server1/ninja/public/invoices/36","previous":"https://server1/ninja/public/invoice    s/36/edit","user_agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko","ip":"1</em>92.168.0.1","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []

The behavior is expected when i set debug mode to true.

When i make an error_log in file “ninja/app/Libraries/CurlUtils.php” on the $response variable the response is a base64 string with debug mode = true (e.g. <head></head><body>data:application/pdf;base64,JVBERi0xLjMKJf////8KNyAwIG9iago8PAovVHlwZSAvRXh0R1N0YXRlCi9jYSAxCj4+CmVuZG9iago4IDAgb2JqCjw8Ci9UeXBlIC9FeHRHU3RhdGUKL0NBIDEKP j4KZW5kb2JqCjUgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAxIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHMgMyAwIFIKL1Jlc291cmNlcyA0IDAgUgo+Pg) and normal source code with debug set to false (e.g.` PHP message: <head>
<!-- Source: https://github.com/invoiceninja/invoiceninja -->
<!-- Version: 3.5.1 -->
<meta charset=“utf-8”>

        &lt;title&gt;Invoice Ninja | Kostenlose Online Open-Source Rechnungsausstellung&lt;/title&gt;
    &lt;meta name="description" content="InvoiceNinja ist eine kostenlose, quelloffene Lösung

chöne Rechnungen erstellen und verschicken, von jedem Gerät mit Internetzugang. Deine Kunden k
en.">
<link href=“https://raspberrypi/ninja/public/favicon-v2.png” rel=“shortcut icon” type=

    &lt;meta property="og:site_name" content="Invoice Ninja"&gt;
    &lt;meta property="og:url" content="https://raspberrypi/ninja/public"&gt;
    &lt;meta property="og:title" content="Invoice Ninja"&gt;
    &lt;meta property="og:image" content="https://raspberrypi/ninja/public/images/round_logo.`).

Does anyone has an idea?