werthdavid / homebridge-website-to-camera

Homebridge plugin that displays a Website as virtual camera (intended for Google Maps Traffic)
MIT License
54 stars 7 forks source link

Protocol error #14

Closed sschuste closed 4 years ago

sschuste commented 4 years ago

Hi,

can you please help me to debug the following output:

[9/24/2019, 9:29:56 AM] [website-camera] Chromium started
[9/24/2019, 9:29:56 AM] [website-camera] Opening new page
[9/24/2019, 9:29:56 AM] [website-camera] Chromium started
[9/24/2019, 9:29:56 AM] [website-camera] Opening new page
[9/24/2019, 9:29:56 AM] [website-camera] Setting Viewport to 960x540
[9/24/2019, 9:29:56 AM] [website-camera] Going to page: https://www.rmv.de/auskunft/bin/jp/stboard.exe/dn?L=vs_anzeigetafel&cfgfile=Schwalbach_3011106_1745928765&start=1
[9/24/2019, 9:29:56 AM] [website-camera] Setting Viewport to 960x540
[9/24/2019, 9:29:56 AM] [website-camera] Going to page: https://www.rmv.de/auskunft/bin/jp/stboard.exe/dn?L=vs_anzeigetafel&cfgfile=FrankfurtM_3000912_1519811804&start=1
[9/24/2019, 9:29:58 AM] [website-camera] Loading finished, waiting 1ms before taking screenshot
[9/24/2019, 9:29:58 AM] [website-camera] Loading finished, waiting 1ms before taking screenshot
[9/24/2019, 9:29:58 AM] [website-camera] { Error: Protocol error (Page.captureScreenshot): Target closed.
    at Promise (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:186:56)
    at new Promise (<anonymous>:null:null)
    at CDPSession.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:185:12)
    at Page._screenshotTask (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Page.js:863:39)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Page.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:144:27)
    at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:36:35)
  message: 'Protocol error (Page.captureScreenshot): Target closed.' }
[9/24/2019, 9:29:58 AM] [website-camera] { Error: Protocol error (Page.captureScreenshot): Target closed.
    at Promise (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:186:56)
    at new Promise (<anonymous>:null:null)
    at CDPSession.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:185:12)
    at Page._screenshotTask (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Page.js:863:39)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Page.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:144:27)
    at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:36:35)
  message: 'Protocol error (Page.captureScreenshot): Target closed.' }

Unfortunately, I have very little further information. The plugin worked without any problems on a Raspi 3B+ with Raspberian Stretch. In the meantime I have had a Raspi 4 with Raspberian Buster for weeks and only noticed today that this error message is generated. Another change in my setup was of course the update to iOS 13, but I can't imagine that this is the reason.

Any idea where to look?

werthdavid commented 4 years ago

Hmm I only have an Rpi3 here but I'll try to reproduce it here. Could be a problem with puppeteer and Chrome versions..

sschuste commented 4 years ago

I finally had time to do some tests. Apparently it's Raspbian Buster. The plugin doesn't run on a Raspi 3 with Buster, but on a Raspi 3 with Raspbian Stretch.

Raspi 4 with Buster: not working Raspi 3 with Buster: not working Raspi 3 with Stretch: working

All test environments are running with node-10.16.3 LTS and homebridge 0.4.50.

werthdavid commented 4 years ago

Ok do u have raspbian with desktop installed? Can you confirm chromium/chrome is running?

werthdavid commented 4 years ago

Can you also try: 1) go to plugin install dir 2) npm i puppeteer-core@latest

And see if that helps?

sschuste commented 4 years ago

Unfortunately, I only have a Raspbian minimal installation, but I used X11 to display the chromium browser on my Mac with xquartz. It works wonderful. The browser is running fine.

As I wasn't sure where exactly to install puppeteer I tried two different approaches:

Installation in /usr/local/lib/node_modules (using sudo npm i -g --unsafe-perm puppeteer-core@latest)

Oct 05 19:50:35 homePi homebridge[24797]: [10/5/2019, 7:50:35 PM] [website-camera] Starting new instance of Chromium: /usr/bin/chromium-browser
Oct 05 19:50:37 homePi homebridge[24797]: [10/5/2019, 7:50:37 PM] [website-camera] Chromium started
Oct 05 19:50:37 homePi homebridge[24797]: [10/5/2019, 7:50:37 PM] [website-camera] Opening new page
Oct 05 19:50:38 homePi homebridge[24797]: [10/5/2019, 7:50:38 PM] [website-camera] Setting Viewport to 960x540
Oct 05 19:50:38 homePi homebridge[24797]: [10/5/2019, 7:50:38 PM] [website-camera] Going to page: https://www.rmv.de/auskunft/bin/jp/stboard.exe/dn?L=vs_anzeigetafel&cfgfile=Schwalbach_3011106_1745928765&start=1
Oct 05 19:50:40 homePi homebridge[24797]: [10/5/2019, 7:50:40 PM] [website-camera] Loading finished, waiting 1ms before taking screenshot
Oct 05 19:50:42 homePi homebridge[24797]: [10/5/2019, 7:50:42 PM] [website-camera] { Error: Protocol error (Page.captureScreenshot): Target closed.
Oct 05 19:50:42 homePi homebridge[24797]:     at Promise (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:186:56)
Oct 05 19:50:42 homePi homebridge[24797]:     at new Promise (<anonymous>:null:null)
Oct 05 19:50:42 homePi homebridge[24797]:     at CDPSession.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:185:12)
Oct 05 19:50:42 homePi homebridge[24797]:     at Page._screenshotTask (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Page.js:863:39)
Oct 05 19:50:42 homePi homebridge[24797]:     at process._tickCallback (internal/process/next_tick.js:68:7)
Oct 05 19:50:42 homePi homebridge[24797]:   -- ASYNC --
Oct 05 19:50:42 homePi homebridge[24797]:     at Page.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:144:27)
Oct 05 19:50:42 homePi homebridge[24797]:     at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:36:35)
Oct 05 19:50:42 homePi homebridge[24797]:   message: 'Protocol error (Page.captureScreenshot): Target closed.' }
Oct 05 19:50:42 homePi homebridge[24797]: [10/5/2019, 7:50:42 PM] [website-camera] { Error: Protocol error (Page.captureScreenshot): Target closed.
Oct 05 19:50:42 homePi homebridge[24797]:     at Promise (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:186:56)
Oct 05 19:50:42 homePi homebridge[24797]:     at new Promise (<anonymous>:null:null)
Oct 05 19:50:42 homePi homebridge[24797]:     at CDPSession.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:185:12)
Oct 05 19:50:42 homePi homebridge[24797]:     at Page._screenshotTask (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Page.js:863:39)
Oct 05 19:50:42 homePi homebridge[24797]:     at process._tickCallback (internal/process/next_tick.js:68:7)
Oct 05 19:50:42 homePi homebridge[24797]:   -- ASYNC --
Oct 05 19:50:42 homePi homebridge[24797]:     at Page.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:144:27)
Oct 05 19:50:42 homePi homebridge[24797]:     at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:36:35)
Oct 05 19:50:42 homePi homebridge[24797]:   message: 'Protocol error (Page.captureScreenshot): Target closed.' }

I de-installed puppeteer and did a Installation in /usr/local/lib/node_modules/homebridge-website-to-camera/ (using cd /usr/local/lib/node_modules/homebridge-website-to-camera/ && sudo npm i --unsafe-perm puppeteer-core@latest) Error: WebSocket is not open: readyState 3 (CLOSED)

werthdavid commented 4 years ago

Dang it... I have one more idea.. I'll create a dev-release tmrw which can be used for testing

werthdavid commented 4 years ago

please try with homebridge-website-to-camera@1.5.0-SNAPSHOT and let me know if that helps

sschuste commented 4 years ago

No. Unfortunately not. I have now simplified my setup and removed all webiste-to-cameras except one to better see what is happening.

The errors between the first call and the next are different. Maybe the error message of the second call is a consequence of the first one. I don't know. But maybe it will help you. That's how it looks:

[10/6/2019, 10:47:57 AM] [website-camera] Starting new instance of Chromium: /usr/bin/chromium-browser
[10/6/2019, 10:47:58 AM] [website-camera] Chromium started
[10/6/2019, 10:47:58 AM] [website-camera] Opening new page
[10/6/2019, 10:47:59 AM] [website-camera] Setting Viewport to 960x540
[10/6/2019, 10:47:59 AM] [Alexa] alexaDiscovery - returned 66 devices
[10/6/2019, 10:47:59 AM] [website-camera] Going to page: https://www.rmv.de/auskunft/bin/jp/stboard.exe/dn?L=vs_anzeigetafel&cfgfile=FrankfurtM_3000912_1519811804&start=1
[10/6/2019, 10:48:00 AM] [website-camera] Loading finished, waiting 1ms before taking screenshot
[10/6/2019, 10:48:01 AM] [website-camera] { Error: Protocol error (Page.captureScreenshot): Target closed.
    at Promise (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:183:56)
    at new Promise (<anonymous>:null:null)
    at CDPSession.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:182:12)
    at Page._screenshotTask (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Page.js:921:39)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Page.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:111:15)
    at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:39:35)
  message: 'Protocol error (Page.captureScreenshot): Target closed.' }

Seconds later, the refresh:

[10/6/2019, 10:48:11 AM] [website-camera] Opening new page
[10/6/2019, 10:48:11 AM] [website-camera] Error: WebSocket is not open: readyState 3 (CLOSED)
    at WebSocket.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/ws/lib/websocket.js:329:19)
    at WebSocketTransport.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/WebSocketTransport.js:60:14)
    at Connection._rawSend (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:86:21)
    at Connection.send (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Connection.js:72:21)
    at Browser._createPageInContext (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Browser.js:174:47)
    at BrowserContext.newPage (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Browser.js:367:26)
    at Browser.newPage (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/Browser.js:166:33)
    at Browser.<anonymous> (/usr/local/lib/node_modules/homebridge-website-to-camera/node_modules/puppeteer-core/lib/helper.js:112:23)
    at ScreenshotHelper.getScreenshot (/usr/local/lib/node_modules/homebridge-website-to-camera/ScreenshotHelper.js:32:37)
    at Camera.handleSnapshotRequest (/usr/local/lib/node_modules/homebridge-website-to-camera/CameraSource.js:66:27)
    at Accessory._handleResource (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:934:25)
    at HAPServer.emit (events.js:198:13)
    at HAPServer._handleResource (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:1035:10)
    at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
    at IncomingMessage.emit (events.js:198:13)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
sschuste commented 4 years ago

Would a log help with homebridge debug mode enabled?

werthdavid commented 4 years ago

Actually not, all logs print to info so that's fine...

werthdavid commented 4 years ago

Can you tell me which version of chromium you are using?

werthdavid commented 4 years ago

Can you contact me via Email so we can find a solution more efficiently?

werthdavid commented 4 years ago

https://github.com/GoogleChrome/puppeteer/issues/1409

sschuste commented 4 years ago

I sent a message to you via email.

werthdavid commented 4 years ago

should be resolved with 1.5.0