vbauer / manet

Website screenshot service powered by Node.js, SlimerJS and PhantomJS
MIT License
575 stars 102 forks source link

Error while sending file: ENOENT #22

Closed AJB99 closed 9 years ago

AJB99 commented 9 years ago

Hi there,

Manet looks like a great private screen cap service, but I'm having some issues standing it up. Here's my specs:

OSX 10.10.2 Phantomjs 1.9.8 (installed globally via npm) manet (installed via npm)

But when I run the following:

$ wget http://localhost:8891/?url=github.com -O ~/github.png
--2015-02-23 18:09:58--  http://localhost:8891/?url=github.com
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8891... failed: Connection refused.
Connecting to localhost|127.0.0.1|:8891... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-02-23 18:10:01 ERROR 404: Not Found.

I get the following:

debug: Execution time: 2 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vdmlzaWEuY2EifQ==
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vdmlzaWEuY2EifQ==.png'
debug: Sending image ("github.com") in response
info: Capture site screenshot: github.com
debug: Options for script: {"url":"http://github.com"}, base64: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9
debug: Process output: Script options: {"url":"http://github.com"}
TypeError: 'undefined' is not a function (evaluating 'Array.prototype.forEach.call.bind(Array.prototype.forEach)')

  https://assets-cdn.github.com/assets/frameworks-9643b0378c6bcb216adcdaaaa703eed77aa239aaf1c2ae44cadb2fb5099ec172.js:29
  https://assets-cdn.github.com/assets/frameworks-9643b0378c6bcb216adcdaaaa703eed77aa239aaf1c2ae44cadb2fb5099ec172.js:29
ReferenceError: Can't find variable: $

  https://assets-cdn.github.com/assets/github-e481d46e78f12279d9b4fec62c9f7f79d748386efa94431f30b84db4fe996902.js:1
  https://assets-cdn.github.com/assets/github-e481d46e78f12279d9b4fec62c9f7f79d748386efa94431f30b84db4fe996902.js:1
Error: Unable to open file 'src/config/default-styles.css'

debug: Execution time: 2.85 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9.png'`

And I've got a default.json config file that looks like so:

{
    "port": 8891,
    "cors": false,
    "ui": true,

    "silent": false,
    "level": "debug",

    "engine": "phantomjs",
    "options": {},
    "timeout": 9000,
    "compress": false,
    "cache": 0,
    "cleanup": false,

    "commands": {
        "slimerjs": {
            "linux": "xvfb-run -a slimerjs",
            "freebsd": "xvfb-run -a slimerjs",
            "sunos": "xvfb-run -a slimerjs",
            "darwin": "slimerjs",
            "win32": "slimerjs.bat"
        },
        "phantomjs": {
            "linux": "phantomjs",
            "freebsd": "phantomjs",
            "sunos": "phantomjs",
            "darwin": "phantomjs",
            "win32": "phantomjs"
        }
    },

    "whitelist": [
        ".*"
    ]
}

Any idea where I should start looking to debug?

Thanks!

vbauer commented 9 years ago

It looks like you don't have file "src/config/default-styles.css" (https://github.com/vbauer/manet/blob/master/src/config/default-styles.css) which was added in the last version..

Could you please check it?

vbauer commented 9 years ago

I've just reproduced this issue, but couldn't find solution. Any idea about calculation relative paths to the local files in PhantomJS/SlimerJS would be great..

vbauer commented 9 years ago

I've just removed this feature in the version 0.3.5 (until we invent something usable). Default styles are hard-coded in the screenshot.js for the current moment.

Could you please try to update Manet to the last version?

alexanderbuhler commented 9 years ago

Same problem here.

Win 8.1 x64, installed phantom manually, version 2.0.0, added to path. Set level to debug.

Node v0.12.0, npm 2.5.1 Doesn't matter if I request it with my browser over localhost or wget it from a remote location

info: Manet server started on port 8891
debug: Sending image ("google.com") in response
info: Capture site screenshot: google.com
debug: Options for script: {"url":"http://google.com"}, base64: eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmNvbSJ9
exec: use child_process.execFile instead
debug: Process output: TypeError: undefined is not an object (evaluating 'phantom.args[index]')

C:\Users\Alexander\AppData\Roaming\npm\node_modules\manet\src\scripts\screenshot.js:26 in argument
C:\Users\Alexander\AppData\Roaming\npm\node_modules\manet\src\scripts\screenshot.js:168
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmNvbSJ9
error: Error while sending file: ENOENT, stat 'C:\Users\ALEXAN~1\AppData\Local\Temp\eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmNvbSJ9.png'
vbauer commented 9 years ago

phantom object was marked as deprecated: http://phantomjs.org/api/phantom/property/args.html It looks like that you use version without this object. I've just fixed it.

alexanderbuhler commented 9 years ago

Hi Vladislav,

thanks for your fast reply! On the one hand the debug looks cleaner, because the TypeError is gone. On the other hand there's still not even network traffic after sending a capture request.

Monitoring my Temp directory, I also can't notice any file getting created. I guess the ENOENT comes from the fact there's no such file to send.

Standalone phantom scripts work fine btw. I see about 3 seconds of network traffic with image rendering afterwards.

info: Capture site screenshot: google.de
debug: Options for script: {"url":"http://google.de"}, base64: eyJ1cmwiOiJodHRwO
i8vZ29vZ2xlLmRlIn0=
debug: Process output:
debug: Execution time: 60.01 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmRlIn0=
error: Error while sending file: ENOENT, stat 'C:\Users\ALEXAN~1\AppData\Local\T
emp\eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmRlIn0=.png'
vbauer commented 9 years ago

Hi Alexander,

It is very strange that execution time: 60.01 secs.. It means that process was killed by timeout. Unfortunately I have not got Windows 8.1, so I can't check it with this environment.

Visgean commented 9 years ago

Can confirm this on latest Ubuntu

geekbleek commented 9 years ago

Hello,

I am also having a similar issue on Centos 7. The issue only occurs when slimerjs is being used as the rendering engine. I really need to use slimerjs as phantomjs just doesn't render modern web pages appropriately anymore.

Here is the execution with the latest 0.3.9 manet version with the same ENOENT error mentioned above:

[centos@jgdemo1 ~]$ sudo /home/centos/nodeprojects/jgdemo/node_modules/manet/bin/manet --port=80 --engine="slimerjs" --level="debug"
info: Initialize FS watchdog: directory: /tmp, timeout: 3600000
debug: Default configuration file: /home/centos/nodeprojects/jgdemo/node_modules/manet/src/config/default.json
debug: Configuration parameters: {"host":"0.0.0.0","port":80,"cors":false,"ui":true,"silent":false,"level":"debug","engine":"slimerjs","options":{},"timeout":60000,"compress":false,"cache":3600,"cleanup":false,"commands":{"slimerjs":{"linux":"xvfb-run -a slimerjs","freebsd":"xvfb-run -a slimerjs","sunos":"xvfb-run -a slimerjs","darwin":"slimerjs","win32":"slimerjs.bat"},"phantomjs":{"linux":"phantomjs","freebsd":"phantomjs","sunos":"phantomjs","darwin":"phantomjs","win32":"phantomjs"}},"whitelist":[".*"],"HOSTNAME":"jgdemo1.novalocal","TERM":"xterm-256color","HISTSIZE":"1000","LS_COLORS":"rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:","MAIL":"/var/spool/mail/centos","LANG":"en_US.UTF-8","SHELL":"/bin/bash","PATH":"/sbin:/bin:/usr/sbin:/usr/bin","LOGNAME":"root","USER":"root","USERNAME":"root","HOME":"/root","SUDO_COMMAND":"/home/centos/nodeprojects/jgdemo/node_modules/manet/bin/manet --port=80 --engine=slimerjs --level=debug","SUDO_USER":"centos","SUDO_UID":"1000","SUDO_GID":"1000","_":[],"$0":"node ./nodeprojects/jgdemo/node_modules/manet/bin/manet","storage":"/tmp"}
info: Manet server started on port 80

debug: Sending image ("github.com") in response
info: Capture site screenshot: github.com
debug: Options for script: {"url":"http://github.com","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1003,"width":1440,"height":960}, base64: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwMywid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==

debug: Process output: Script options: {"url":"http://github.com","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1003,"width":1440,"height":960}

debug: Execution time: 4.81 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwMywid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwMywid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==.png'

And here with the timeout set upon execution with no effect:

[centos@jgdemo1 ~]$ sudo /home/centos/nodeprojects/jgdemo/node_modules/manet/bin/manet --port=80 -ngine="slimerjs" --level="debug" --timeout=120000
info: Initialize FS watchdog: directory: /tmp, timeout: 3600000
debug: Default configuration file: /home/centos/nodeprojects/jgdemo/node_modules/manet/src/config/default.json
debug: Configuration parameters: {"host":"0.0.0.0","port":80,"cors":false,"ui":true,"silent":false,"level":"debug","engine":"slimerjs","options":{},"timeout":120000,"compress":false,"cache":3600,"cleanup":false,"commands":{"slimerjs":{"linux":"xvfb-run -a slimerjs","freebsd":"xvfb-run -a slimerjs","sunos":"xvfb-run -a slimerjs","darwin":"slimerjs","win32":"slimerjs.bat"},"phantomjs":{"linux":"phantomjs","freebsd":"phantomjs","sunos":"phantomjs","darwin":"phantomjs","win32":"phantomjs"}},"whitelist":[".*"],"HOSTNAME":"jgdemo1.novalocal","TERM":"xterm-256color","HISTSIZE":"1000","LS_COLORS":"rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:","MAIL":"/var/spool/mail/centos","LANG":"en_US.UTF-8","SHELL":"/bin/bash","PATH":"/sbin:/bin:/usr/sbin:/usr/bin","LOGNAME":"root","USER":"root","USERNAME":"root","HOME":"/root","SUDO_COMMAND":"/home/centos/nodeprojects/jgdemo/node_modules/manet/bin/manet --port=80 --engine=slimerjs --level=debug --timeout=120000","SUDO_USER":"centos","SUDO_UID":"1000","SUDO_GID":"1000","_":[],"$0":"node ./nodeprojects/jgdemo/node_modules/manet/bin/manet","storage":"/tmp"}
info: Manet server started on port 80

debug: Sending image ("github.com") in response
info: Capture site screenshot: github.com
debug: Options for script: {"url":"http://github.com","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1004,"width":1440,"height":960}, base64: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==
debug: Process output: Script options: {"url":"http://github.com","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1004,"width":1440,"height":960}

debug: Execution time: 4.5 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==.png'

I have monitored the /tmp file system and see no files being generated. Any ideas on logs/debugs I could turn on within slimerjs to see whats occurring?

This is repeatable on a number of websites (and consistently on those websites) but still works on others (within the same execution of manet):

debug: Sending image ("nyc.gov") in response
info: Capture site screenshot: nyc.gov
debug: Options for script: {"url":"http://nyc.gov","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1004,"width":1440,"height":960}, base64: eyJ1cmwiOiJodHRwOi8vbnljLmdvdiIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==

debug: Process output: Script options: {"url":"http://nyc.gov","agent":"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0","delay":1004,"width":1440,"height":960}

Script Error: NS_ERROR_FACTORY_NOT_REGISTERED: 
       Stack:
         -> https://translate.googleapis.com/translate_static/js/element/26/element_main.js: 411

Rendered screenshot: /tmp/eyJ1cmwiOiJodHRwOi8vbnljLmdvdiIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==.png

debug: Execution time: 19.49 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vbnljLmdvdiIsImFnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4zOyBydjozNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzM2LjAiLCJkZWxheSI6MTAwNCwid2lkdGgiOjE0NDAsImhlaWdodCI6OTYwfQ==

Please let me know if there is anything I can provide to help debug this issue! Also - is there anyway to instantiate manet from within node/express? I don't want to expose manet to be able to render just ANY webshot (I want to use it to pull a snapshot and embed it in a rendered webpage). I tried using webshot from the NPM library but it only uses phantomjs and renders some pages poorly.

vbauer commented 9 years ago

I think that the current state of this issue was described here: https://github.com/vbauer/manet/issues/10

@cbleeker You can try to remove "agent" parameter (if it's possible). It could help as workaround, but I understand that #10 should be fixed to resolve this problem completely.