node-webshot icon indicating copy to clipboard operation
node-webshot copied to clipboard

Fail to take the screenshot with some url

Open matiasfha opened this issue 11 years ago • 9 comments

I have this code

webshot url, (err, stream) ->
gm(stream, filename + extension).write directory + filename + extension, (err) ->
    if err
        console.log 'err:', err
    else
        console.log 'success'

It's works!, but with some url, just not render de image, The url for test: https://medium.com/@moon_beamed/on-going-viral-62a3e71ddac4 i'm get

{ [Error: Command failed: gm convert: Improper image header (/var/folders/qp/g6h_g57n7m51l2qb_np957kh0000gn/T/gmfXs0zO).] code: 1, signal: null }

if i don't use gm

webshot url, directory + filename + extension, (err)  ->
if !err
    console.log 'saved'
else
    console.log 'err:', err

i get

err: [Error: PhantomJS exited with return value 1]

matiasfha avatar Aug 21 '14 02:08 matiasfha

I was able to reproduce this issue with the URL given with just phantomJS. This an ssl error with phatomJS that isn't getting reported well, but basically the default configuration has a set of allowed SSL protocols and the server that site/url is using a different one,

Fix: if you use the "--ssl-protocol=any" with phantomJS it works.

More information can be found here: http://stackoverflow.com/questions/12021578/phantomjs-failing-to-open-https-site

Simply pass that configuration to phantomJS with webshot (check the readme) and I think you should be set.

Note: This isn't something webshot should automatically do for you. The developer needs to decide to overwrite the ssl settings for themselves, so I'd say add a note in the readme and close the ticket.

LorenzGardner avatar Aug 21 '14 19:08 LorenzGardner

:+1:

nadav-dav avatar Sep 04 '15 14:09 nadav-dav

How exactly do I pass the "--ssl-protocol=any" in to the webshot function ? .. found it, "phantomConfig"

I upgraded to phantom 2.x .. and ran with phantomConfig: { "ssl-protocol":"ANY", 'ignore-ssl-errors': 'true' }

.. still getting this.. err: [Error: PhantomJS exited with return value 1]
error..

weird thing is I get this on my AWS box but not on my localhost.

Shic1983 avatar Jan 26 '16 08:01 Shic1983

I am using PhantomJS 2.1.1 and phantomConfig: { "ssl-protocol":"ANY", 'ignore-ssl-errors': 'true' }. Even though its giving same error [Error: PhantomJS exited with return value 1]

a1Gupta avatar Mar 27 '16 07:03 a1Gupta

PhantomJS exited with return value 1, just tells us that PhatomJS had an error. It does not tell us what the error was. In the original issue the error was related to an SSL compatibility issue. That may have nothing to do with your problems.

Try to connect to the site with just PhantomJS, and look at the error PhatomJS is giving you. Webshot should probably bubble up the error, but (unless something has change recently) currently does not.

LorenzGardner avatar Mar 28 '16 13:03 LorenzGardner

:+1:

rm3nchaca avatar Aug 04 '16 17:08 rm3nchaca

Is there any solution for [Error: PhantomJS exited with return value 1] ? I am using this module (node-webshot) with SailsJS, seems it's working fine on my local setup but on Amazon linux server getting this error.

FYI: If I run a raw phantomjs test.js with some code it seems working fine but when I try to get a screenshot using webshot I am getting this error though I am using phantomConfig: { "ssl-protocol":"any"}

Any suggestion?

juyal-ahmed avatar Sep 06 '16 09:09 juyal-ahmed

Any update on this? I'm getting this error usnig webshot

adonespitogo avatar Mar 02 '17 16:03 adonespitogo

I just ran into this issue as well. It seems that when you supply phantomConfig for ssl purpose, you will need to define phantomPath as well. I added that and it works.

AiolosHui avatar Jan 09 '18 09:01 AiolosHui