Closed FabioEight closed 1 year ago
Hi, the option already exists. Any scripts in /config/browserless_chrome.sh will be executed at boot (the exact path for the script is described in the log)
In a future version of my script, all scripts will be copied to /config/addons_autoscripts to centralise them. It will be done automatically so no action required on your side
Awesome, thanks for your reply. I'm having some issues already at the testing stage, I use the following code in browserless:
const webdriver = require('selenium-webdriver');
const fs = require('fs');
const chromeCapabilities = webdriver.Capabilities.chrome();
chromeCapabilities.set(
'chromeOptions', {
args: [
'--headless',
'--no-sandbox',
'--whitelisted-ips=""'
'--base-url /' #same parameters used in my ssh script
],
}
);
const driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(chromeCapabilities)
.usingServer('http://192.168.1.X:3000/webdriver') // my HAOS local IP
.build();
From NodeRed I have this error while trying to opening a new session:
27 Dec 17:02:29 - [info] [open browser:FLOW] http://192.168.1.X:3000/ is reacheable by Node-red
[TRACE][2022-12-27T16:03:20.421Z][Object.<anonymous>|api.js:40] Calling : POST http://192.168.1.X:3000/session
27 Dec 17:03:20 - [error] [open browser:FLOW] Can't open an instance of chrome
27 Dec 17:03:20 - [error] [open browser:FLOW] Error: Incorrect HTTP header 'content-type', expected 'application/json'
Instead, from the browserless chrome logs I don't have any useful information:
2022-12-27T16:15:32.671Z browserless:chrome-helper Injecting download dir "/usr/src/app/workspace"
2022-12-27T16:15:32.672Z browserless:chrome-helper Setting up file:// protocol request rejection
2022-12-27T16:15:33.168Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: /: Inbound WebSocket request.
2022-12-27T16:15:33.171Z browserless:hardware Checking overload status: CPU 16% Memory 29%
2022-12-27T16:15:33.171Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Adding new job to queue.
2022-12-27T16:15:33.171Z browserless:server Starting new job
2022-12-27T16:15:33.171Z browserless:system Generating fresh chrome browser
2022-12-27T16:15:33.171Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Getting browser.
2022-12-27T16:15:33.172Z browserless:chrome-helper Launching Chrome with args: {
"args": [
"--no-sandbox",
"--enable-logging",
"--v1=1",
"--disable-dev-shm-usage",
"--no-first-run",
"--remote-debugging-port=33001",
"--user-data-dir=/data/profile",
"--remote-debugging-pipe"
],
"blockAds": false,
"dumpio": false,
"headless": true,
"stealth": false,
"ignoreDefaultArgs": false,
"ignoreHTTPSErrors": false,
"pauseOnConnect": false,
"playwright": false,
"userDataDir": "/data/profile",
"meta": {
"protocol": null,
"slashes": null,
"auth": null,
"host": null,
"port": null,
"hostname": null,
"hash": null,
"search": null,
"query": {},
"pathname": "/",
"path": "/",
"href": "/"
},
"executablePath": "/usr/bin/google-chrome",
"handleSIGINT": false,
"handleSIGTERM": false,
"handleSIGHUP": false
}
2022-12-27T16:15:33.330Z browserless:chrome-helper Chrome PID: 297
2022-12-27T16:15:33.331Z browserless:chrome-helper Finding prior pages
2022-12-27T16:15:33.352Z browserless:chrome-helper Found 1 pages
2022-12-27T16:15:33.352Z browserless:chrome-helper Setting up page Unknown
2022-12-27T16:15:33.352Z browserless:chrome-helper Injecting download dir "/usr/src/app/workspace"
2022-12-27T16:15:33.352Z browserless:system Chrome launched 181ms
2022-12-27T16:15:33.353Z browserless:system Got chrome instance
2022-12-27T16:15:33.353Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Starting session.
2022-12-27T16:15:33.354Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Proxying request to /devtools/browser route: ws://127.0.0.1:33001/devtools/browser/36e55141-2db8-491a-b1f0-9b82e0353338.
2022-12-27T16:15:33.355Z browserless:chrome-helper Setting up file:// protocol request rejection
2022-12-27T16:15:33.433Z browserless:chrome-helper Setting up page Unknown
2022-12-27T16:15:33.433Z browserless:chrome-helper Injecting download dir "/usr/src/app/workspace"
2022-12-27T16:15:33.434Z browserless:chrome-helper Setting up file:// protocol request rejection
2022-12-27T16:15:34.185Z browserless:job 893AGGS01W8WN079743J5YZLZIDFOMP7: /devtools/page/70DD7627841FDDDDD98CFAE614C248BF: Inbound WebSocket request.
2022-12-27T16:16:32.440Z browserless:server YNS95LTJYUUEBX1LG9JKQ0R4HMQX9SSV: Recording timedout stat.
2022-12-27T16:16:32.440Z browserless:job YNS95LTJYUUEBX1LG9JKQ0R4HMQX9SSV: Job has timed-out, closing the WebSocket.
2022-12-27T16:16:32.441Z browserless:job YNS95LTJYUUEBX1LG9JKQ0R4HMQX9SSV: Cleaning up job
2022-12-27T16:16:32.441Z browserless:job YNS95LTJYUUEBX1LG9JKQ0R4HMQX9SSV: Browser not needed, closing
2022-12-27T16:16:32.441Z browserless:chrome-helper Shutting down browser with close command
2022-12-27T16:16:32.441Z browserless:job YNS95LTJYUUEBX1LG9JKQ0R4HMQX9SSV: Browser cleanup complete.
2022-12-27T16:16:32.441Z browserless:chrome-helper Sending SIGKILL signal to browser process 239
2022-12-27T16:16:32.456Z browserless:server Error with inbound socket Error [ERR_STREAM_WRITE_AFTER_END]: write after end
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at new NodeError (node:internal/errors:387:5)
at _write (node:internal/streams/writable:321:11)
at Socket.Writable.write (node:internal/streams/writable:336:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
2022-12-27T16:16:32.473Z browserless:chrome-helper Garbage collecting and removing listeners
2022-12-27T16:16:33.170Z browserless:server 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Recording timedout stat.
2022-12-27T16:16:33.170Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Job has timed-out, closing the WebSocket.
2022-12-27T16:16:33.170Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Cleaning up job
2022-12-27T16:16:33.171Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Browser not needed, closing
2022-12-27T16:16:33.171Z browserless:chrome-helper Shutting down browser with close command
2022-12-27T16:16:33.171Z browserless:job 5HHOOR97E6QLTIUQZPCH2WJGJB3N6FJ0: Browser cleanup complete.
2022-12-27T16:16:33.171Z browserless:server Current workload complete.
2022-12-27T16:16:33.171Z browserless:chrome-helper Sending SIGKILL signal to browser process 297
2022-12-27T16:16:33.184Z browserless:server Error with inbound socket Error [ERR_STREAM_WRITE_AFTER_END]: write after end
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at new NodeError (node:internal/errors:387:5)
at _write (node:internal/streams/writable:321:11)
at Socket.Writable.write (node:internal/streams/writable:336:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
2022-12-27T16:16:33.203Z browserless:chrome-helper Garbage collecting and removing listeners
It is also strange that the arguments provided by the browserless webgui are not shown in the logs..
This Addon is super simple shell around the official docker image. Have you checked on their repo if there is anything that could help? Looks like the error is Incorrect HTTP header 'content-type', expected 'application/json'
Yes, I tried the quick start steps but no luck. Will investigate further. By the way, this might not be the correct way to ask, but do you think it's possible to create an addon of chromedriver or any other Selenium based webdriver for this purpose? Thanks for your effort!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello,
Is it possible to execute a default script in browserless chrome at the addon startup? I have a NodeRed flow using Selenium to reach and interact with several webpages. Currently the webdriver is hosted on a secondary device in my network and I would like to move all to HAOS. Basically I just need to launch the browserless-chrome webdriver at every startup of the addon.
Thank you!