stefanzweifel / screeenly

📸 Screenshot as a Service
https://secure.screeenly.com
MIT License
495 stars 102 forks source link

New local install gives "Something went wrong capturing this website" #314

Closed ccandreva closed 4 years ago

ccandreva commented 4 years ago

I have just installed a Screeenly locally. I have laravel running, and storage/testing has a test-screenshot of a german google page. However when I try to take a screenshot using the web site I get a red box with this message:

Something went wrong capturing this website. Is it a Javascript heavy site or loads lots of external content? If you think this is an error contact us.

No error messages are logged at all. I'm not sure where to look next ?

stefanzweifel commented 4 years ago

Hi,

Have you followed the self hosting guide? https://github.com/stefanzweifel/screeenly/wiki/Requirements-and-Install#server-requirements

Did you also install the NPM dependencies with npm install/yarn?

Is Google Chrome installed?

hadogenes commented 4 years ago

I have same error. Do I need Chrome or can I use Chromium?

stefanzweifel commented 4 years ago

@hadogenes Chrome or Chromium, it doesn't really matter :)

Under the hood screeenly uses spatie/browsershot. You can find more information what is required in their documentation.

hadogenes commented 4 years ago

still have this error - where are logs to check what is going on?

stefanzweifel commented 4 years ago

Try removing the try/catch-block here:

https://github.com/stefanzweifel/screeenly/blob/fb2bab013341cdfa953fa7a4ed0c053e5655cde6/modules/Screeenly/Http/Controllers/App/TryController.php#L31-L45

The store method would then only contain the following:

$screenshot = $captureService
    ->width(1440)
    ->delay(1)
    ->url(new Url($request->url))
    ->capture();
$screenshot->delete();
return redirect('try')->with('base64', $screenshot->getBase64());

Depending on your setup, you might have to rewrite some parts of ChromeBrowser

https://github.com/stefanzweifel/screeenly/blob/fb2bab013341cdfa953fa7a4ed0c053e5655cde6/modules/Screeenly/Services/ChromeBrowser.php#L14

Here's the list of all the config options of browsershot: https://github.com/spatie/browsershot#custom-node-and-npm-binaries

(Sorry, clicked closed on accident 🙃)

hadogenes commented 4 years ago

I have error

The process "PATH=$PATH:/usr/local/bin NODE_PATH=npm root -g node '/var/www/screeenly/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"https:\/\/en.wikipedia.org\/wiki\/Special:Random","action":"screenshot","options":{"type":"png","path":"\/var\/www\/screeenly\/storage\/app\/public\/5d9b10ec71a54_8bIaPZZGAkxKTkOEIhGd1FScghydQe.jpg","args":["--no-sandbox"],"viewport":{"width":1440,"height":768},"ignoreHttpsErrors":true,"timeout":30000,"delay":100,"userAgent":"screeenly-bot 2.0","fullPage":true}}'" exceeded the timeout of 30 seconds.

hadogenes commented 4 years ago

When I change timeout in modules/Screeenly/Services/ChromeBrowser.php I have

Illuminate \ Contracts \ Filesystem \ FileNotFoundException 5d9b134f2626f_QNTLGLJaBxB7dhEVzciaasagWYUJqz.jpg Previous exceptions File not found at path: 5d9b134f2626f_QNTLGLJaBxB7dhEVzciaasagWYUJqz.jpg

but the file _/var/www/screeenly/storage/app/public/5d9b134f2626fQNTLGLJaBxB7dhEVzciaasagWYUJqz.jpg exists

hadogenes commented 4 years ago

I think that https://github.com/stefanzweifel/screeenly/blob/fb2bab013341cdfa953fa7a4ed0c053e5655cde6/modules/Screeenly/Entities/Screenshot.php#L36 should take $absolutePath

hadogenes commented 4 years ago

No it don't work I get file (_var/www/screeenly/storage/app/public/5d9b19930bb4c7JbWELFMR8E44qdKoVm1jCbNP2RL0g.jpg) not found - no slash at beginning

stefanzweifel commented 4 years ago

Could you try to run the following in the console in the root of your project?

php artisan storage:link

I think that process is automated, but maybe this didn't work on your machine?


The node error is one of the biggest problems screeenly internally has. As you probably saw, this is a PHP application, but the most important part of it runs on node; and is burried in 2-3 other depenencies.

I've seen the error also on the hosted version on screeenly.com, but I could never reproduce it with 100% accouracy.


Updating the code in Entities/Screenshot might work for your installation, but I would have to check, if the testsuite covered that part of the app, and if it wouldn't break other things.


I've had the same errors both of you are reporting on my end as well. Everytime it was related to the Chrome/Chromium installation. After I've installed Chrome on my DigitalOcean Droplet, everything worked fine

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium

Maybe you can try to use the underlying tools directly?

Or maybe it's because of the machine screeenly is running on.

hadogenes commented 4 years ago

I have low power Intel Atom server - with 4 GB RAM

$ php artisan storage:link
The "public/storage" directory already exists.

I'm trying to run in docker, not ionphractal one, but updated

hadogenes commented 4 years ago

I'm using apache config

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName screen.DOMAIN.TLD

        ServerAdmin admin@DMN.TLD
        DocumentRoot /var/www/screeenly/public

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

<Directory /var/www/screeenly/>
        Options +FollowSymlinks
        AllowOverride All
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ccandreva commented 4 years ago

Once I commented out the try/catch block I was able to see the errors and find my problem. On REL 7, max_user_namespaces defaults to 0, so chrome couldn't clone a name space. Increaseing that allowed chrome to start.

# echo 640 > /proc/sys/user/max_user_namespaces

hadogenes commented 4 years ago

ok I found error: unset FILESYSTEM_DRIVER

stefanzweifel commented 4 years ago

@hadogenes I've updated the default filesystem driver to be public in e71182e6e9831fd0f6e8237ee0387a00ccbd7e9a, as public is the value that should be set anyway.

Can we close this issue now?

ccandreva commented 4 years ago

From my standpoint, yes. Thank you !