Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol error #120

Closed
alex88 opened this issue Mar 9, 2018 · 4 comments
Closed

Protocol error #120

alex88 opened this issue Mar 9, 2018 · 4 comments

Comments

@alex88
Copy link

alex88 commented Mar 9, 2018

I've deployed the sample project with npm run deploy and trying to run a screenshot using an url like: https://xxx.execute-api.eu-west-1.amazonaws.com/dev/pdf?url=https://www.google.com

I get this in the logs

START RequestId: 3b3c44e0-2363-11e8-95de-8539abc1c0b2 Version: $LATEST
2018-03-09T06:29:33.745Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	@serverless-chrome/lambda: Spawning headless shell
2018-03-09T06:29:33.746Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	@serverless-chrome/lambda: It took 1ms to spawn chrome.
2018-03-09T06:29:33.746Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Processing PDFification for https://google.com { landscape: false,
displayHeaderFooter: false,
printBackground: true,
scale: 1,
paperWidth: 8.27,
paperHeight: 11.69,
marginTop: 0,
marginBottom: 0,
marginLeft: 0,
marginRight: 0,
pageRanges: '' }
2018-03-09T06:29:34.012Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Chrome is sending request for: 728953A5F85AADC2500ECFD058F7C6F https://google.com/
2018-03-09T06:29:34.013Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Chrome is sending request for: 728953A5F85AADC2500ECFD058F7C6F https://www.google.ie/?gws_rd=cr&dcr=0&ei=zSmiWvPaMcjegAaEypmABQ
2018-03-09T06:29:34.114Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Chrome received response for: 728953A5F85AADC2500ECFD058F7C6F https://www.google.ie/?gws_rd=cr&dcr=0&ei=zSmiWvPaMcjegAaEypmABQ
2018-03-09T06:29:35.022Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Request queue size: 0 []
2018-03-09T06:29:35.022Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	We think the page has finished loading. Printing PDF.
2018-03-09T06:29:35.028Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	{ Error: Printing failed
at ProtocolError (/var/task/src/handlers/pdf.js:3447:9)
at /var/task/src/handlers/pdf.js:3519:30
at Chrome.handleMessage (/var/task/src/handlers/pdf.js:3720:13)
at WebSocket.<anonymous> (/var/task/src/handlers/pdf.js:3697:27)
at emitOne (events.js:96:13)
at WebSocket.emit (events.js:188:7)
at Receiver._receiver.onmessage (/var/task/src/handlers/pdf.js:1065:47)
at Receiver.dataMessage (/var/task/src/handlers/pdf.js:2259:14)
at perMessageDeflate.decompress (/var/task/src/handlers/pdf.js:2219:40)
at _decompress (/var/task/src/handlers/pdf.js:437:9) response: { code: -32000, message: 'Printing failed' } }
2018-03-09T06:29:35.030Z	3b3c44e0-2363-11e8-95de-8539abc1c0b2	Chromium took 1284ms to load URL and render PDF.
END RequestId: 3b3c44e0-2363-11e8-95de-8539abc1c0b2
REPORT RequestId: 3b3c44e0-2363-11e8-95de-8539abc1c0b2	Duration: 1296.94 ms	Billed Duration: 1300 ms Memory Size: 3008 MB	Max Memory Used: 219 MB	

is it supposed to work?

Trying to screenshot I get a blank output

@alex88 alex88 closed this as completed Mar 9, 2018
@alex88 alex88 reopened this Mar 9, 2018
@TamasNo1
Copy link

Hey @alex88, I had the same issue, just use node v6.10 when installing packages:

rm -rf node_modules
nvm install v6.10
npm install
npm run deploy

Hope this helps!

If not, I made this work by using an earlier version of the repo, give that a try as well:

serverless create -u \
  https://github.com/adieuadieu/serverless-chrome/tree/e95f3030ab6eb03cb700df501f140a9aa4296b64/examples/serverless-framework/aws

@willjosefi
Copy link

willjosefi commented Mar 13, 2018

@TamasNo1 your second solution works for me.
Maybe something related to serverless-plugin-chrome?
Seems the only "main" difference comparing with master branch

nsfmc added a commit to nsfmc/chromeless that referenced this issue Mar 13, 2018
This fixes the vague `Error: Unknown command: protocol` error (schickling#387).

pinned version found via a similar issue report:
adieuadieu/serverless-chrome#120
@Taylorsuk
Copy link

I've had the exact same issue, using the older version :

  https://github.com/adieuadieu/serverless-chrome/tree/e95f3030ab6eb03cb700df501f140a9aa4296b64/examples/serverless-framework/aws

worked for me... I will try and figure out the real difference between the two later today.

thanks @TamasNo1

@jaypea
Copy link

jaypea commented May 9, 2018

I've found the problem. It is a parameter, which was removed in the later chrome versions. to be specific, devtools protocol version 1.2 has a fitwindow flag in Emulation.setDeviceMetricsOverride which is gone in protocol version 1.3.
just remove this flag in

await Emulation.setDeviceMetricsOverride({
      mobile: !!mobile,
      deviceScaleFactor: 0,
      scale: 1, // mobile ? 2 : 1,
      // fitWindow: false,
      width: mobile ? 375 : 1280,
      height
    });

and it should work with the latest chrome versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants