PDFs not attched to emails using local phantomjs

Hey, there

I’m hosting a local invoice ninja(4.2.0) with a local phantomjs, and I found this topic discussing the issue with sending emails with a local phantomjs. If i follow the provided solutions, IN reports an internal server error, if I remove the additions to the CurlUtils.php, the email sends but without the email attached.
I’m at a loss as to how sort this out.

Have you seen the troubleshooting steps here:

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

This is the output the test.pjs script

\n{
    "contentType": null,
    "headers": [],
    "id": 1,
    "redirectURL": null,
    "stage": "end",
    "status": null,
    "statusText": null,
    "time": "2018-02-27T18:31:20.222Z",
    "url": "http://www.ninja.test/view/83urx5vfokh73w3ya5bf1os6boxgtqzr?phantomjs=true&phantomjs_secret=:",
    "console": []
}

That doesn’t look correct, have you tried all of the troubleshooting steps?

You may want to use phatomjscloud.

What do you see if you run phantomjs -v

phantomjs -v returns
2.1.1

I’m not sure, maybe use phantomjscloud instead?

How would I get the phantomjscloud working? I don’t see configuration instructions for it?

Comment out PHANTOMJS_BIN_PATH and make sure the following line is there

PHANTOMJS_CLOUD_KEY=‘a-demo-key-with-low-quota-per-ip-address’

Ok, where do i get the demo key from? Do i have to sign up to the phantomjscloud service to get it?

A free account on PhantomJS Cloud provides an API key that allows upto 500 pages per day.

I get this error in laravel-error.log when I switch to the phantomsjs cloud:

[2018-03-02 09:07:41] production.ERROR: PhantomJS - Invalid response http://www.ninja.test/view/83urx5vfokh73w3ya5bf1os6boxgtqzr?phantomjs=true&phantomjs_secret=: {"context":"PHP","user_id":1,"account_id":1,"user_name":"FirstName LastName","method":"PUT","url":"https://192.168.178.101/quotes/47","previous":"https://192.168.178.101/quotes/47/edit","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0","ip":"192.168.178.26","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []

Have you tried replacing 2.1.1 with the precompiled 2.1.3 binary from phantomjs.org?

sudo apt remove phantomjs, then sudo apt autoremove to get rid of the now unused dependencies.

Then just use wget https://github.com/ariya/phantomjs/releases/download/2.1.3/phantomjs, give ownership of the file to root:root, chmod 755, then drop it in /usr/bin/, and make sure your .env file has a line for PHANTOMJS_BIN_PATH=/usr/bin/phantomjs

wget https://github.com/ariya/phantomjs/releases/download/2.1.3/phantomjs returns

HTTP request sent, awaiting response... 404 Not Found
2018-03-05 16:31:21 ERROR 404: Not Found.

It would appear they removed the 2.1.3 binary, as it’s not even showing up on their download page anymore. @Hillel, might want to remove the link to that thread in the documentation for now, since the link I had is pointing to nowhere at the moment.

The PhantomJS Cloud version might be the way to go for now. I’ll have to build and test the 2.1.1 source to see if that works any better than what’s in apt, but not sure when I’ll be able to get around to that.

Alternatively, you could try the precompiled 2.1.1 binary available at http://phantomjs.org/download.html, but make sure you have Fontconfig installed as well. The process would be the same as I described for 2.1.3, except having to extract the file from the archive first (it will be in phantomjs-2.1.1-linux-x86_64/bin or phantomjs-2.1.1-linux-i686/bin once extracted).

It may be related to this: https://github.com/ariya/phantomjs/issues/15344

PDFs still not attached.

Still getting this error with the test.pjs:

\n{
    "contentType": null,
    "headers": [],
    "id": 1,
    "redirectURL": null,
    "stage": "end",
    "status": null,
    "statusText": null,
    "time": "2018-03-06T06:23:11.437Z",
    "url": "http://www.ninja.test/view/83urx5vfokh73w3ya5bf1os6boxgtqzr?phantomjs=true&phantomjs_secret=:",
    "console": []
}

I think the problem may be related to how the app is hosted. I see the URL is https://192.168.178.101, if the app isn’t publicly available phantomjscloud won’t work as it can’t reach it.

Not sure though why phantomjs isn’t working when it’s running locally, you may want to see if disabling HTTPS helps.

Reaching the IN installation with plain http results in a 404 page(nginx). Unless you mean disable https in some other sense, in which case, I’m not familiar with the option.

To test this you’d need to change the nginx configuration.