brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 285 forks source link

Fail to take the screenshot with some url #78

Open matiasfha opened 10 years ago

matiasfha commented 10 years ago

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]
LorenzGardner commented 10 years ago

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.

nadav-dav commented 9 years ago

:+1:

Shic1983 commented 8 years ago

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.

a1Gupta commented 8 years ago

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]

LorenzGardner commented 8 years ago

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.

rm3nchaca commented 8 years ago

:+1:

juyal-ahmed commented 8 years ago

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?

adonespitogo commented 7 years ago

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

AiolosHui commented 6 years ago

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.