fzaninotto / screenshot-as-a-service

Website screenshot service powered by node.js and phantomjs
1.1k stars 243 forks source link

run curl http://localhost:3000/?url=www.google.com > google.png get error #81

Open scdxcc opened 7 years ago

scdxcc commented 7 years ago

Error at Request._callback (/home/app/screenshot-as-a-service/routes/index.js:82:25) at Request.self.callback (/home/app/screenshot-as-a-service/node_modules/request/main.js:119:22) at Request. (/home/app/screenshot-as-a-service/node_modules/request/main.js:212:58) at emitOne (events.js:77:13) at Request.emit (events.js:169:7) at ClientRequest.self.clientErrorHandler (/home/screenshot-as-a-service/node_modules/request/main.js:209:10) at emitOne (events.js:77:13) at ClientRequest.emit (events.js:169:7) at Socket.socketErrorListener (_http_client.js:267:9) at emitOne (events.js:77:13)

varunsharma27 commented 7 years ago

Same Here :-

Express server listening on 127.0.0.1:3000
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')

phantomjs output:   phantomjs://code/rasterizer.js:9 in global code

Request for http://www.google.com - Rasterizing it
Error while requesting the rasterizer: connect ECONNREFUSED 127.0.0.1:3001
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
Error
    at Request._callback (/home/vsharma/Desktop/Learning/PhantomJs/screenshot-as-a-service/routes/index.js:82:25)
    at Request.self.callback (/home/vsharma/Desktop/Learning/PhantomJs/screenshot-as-a-service/node_modules/request/main.js:119:22)
    at Request.<anonymous> (/home/vsharma/Desktop/Learning/PhantomJs/screenshot-as-a-service/node_modules/request/main.js:212:58)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at ClientRequest.self.clientErrorHandler (/home/vsharma/Desktop/Learning/PhantomJs/screenshot-as-a-service/node_modules/request/main.js:209:10)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')

phantomjs output:   phantomjs://code/rasterizer.js:9 in global code

Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')
varunsharma27 commented 7 years ago

This is happening because we are using PhantomJs 2+. To fix this issue, go to ./screenshot-as-a-service/scripts/rasterizer.js

And add these LOC at the top :-

var system = require('system');
if (typeof(phantom.args) === 'undefined') {
 phantom.args = system.args.slice(1);
}
makehavoc commented 6 years ago

@varundbest Thank you. Your code added to the top of ./screenshot-as-a-service/scripts/rasterizer.js made it work.