ulixee / hero

The web browser built for scraping
MIT License
647 stars 32 forks source link

showChrome doesn't work #242

Open Allamaris0 opened 7 months ago

Allamaris0 commented 7 months ago

Hello. I'm a beginner and I got error at start with an example code :(

`const Hero = require('@ulixee/hero');

// process.env.ULX_SHOW_CHROME = 'true';

(async () => { const url = https://dataliberationfoundation.org/; console.log('Opened Browser'); const hero = new Hero({ showChromeInteractions: true, showChrome: true });

await hero.goto(url, 5e3); await hero.waitForPaintingStable();

await hero.waitForMillis(5e3); await hero.close(); })();`

`Opened Browser

node:internal/process/promises:289 triggerUncaughtException(err, true / fromPromise /); ^ DisconnectedFromCore: This transport has been disconnected (host: This Hero has been disconnected from Core (coreHost: ws://localhost:1818/hero)) at ConnectionToHeroCore.beforeDisconnect (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\connections\ConnectionToHeroCore.ts:114:11) at ConnectionToHeroCore.onConnectionTerminated (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\net\lib\ConnectionToCore.ts:243:42) at WsTransportToCore.finalHandler (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\commons\lib\EventSubscriber.ts:46:14) at Object.onceWrapper (node:events:629:26) at WsTransportToCore.emit (node:events:514:28) at WsTransportToCore.emit (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\commons\lib\TypedEventEmitter.ts:158:18) at WsTransportToCore.disconnect (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\net\lib\WsTransportToCore.ts:60:10) at WebSocket.finalHandler (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\commons\lib\EventSubscriber.ts:46:14) at Object.onceWrapper (node:events:629:26) at WebSocket.emit (node:events:514:28) ------AGENT QUEUE--------------------------------- at Queue.run (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\commons\lib\Queue.ts:63:19) at CoreSessions.create (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\lib\CoreSessions.ts:34:8) at ConnectionToHeroCore.createSession (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\connections\ConnectionToHeroCore.ts:67:38) at Hero._Hero_getCoreSessionOrReject (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\lib\Hero.ts:679:10) at Hero.get activeTab [as activeTab] (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\lib\Hero.ts:176:33) at Hero.goto (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\node_modules\client\lib\Hero.ts:470:17) at C:\Users\Emilia\PhpstormProjects\hero\hero\examples\show-browser.js:10:14 at Object. (C:\Users\Emilia\PhpstormProjects\hero\hero\examples\show-browser.js:15:3) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) { host: 'This Hero has been disconnected from Core (coreHost: ws://localhost:1818/hero)', code: 'DisconnectedFromCore', coreHost: 'ws://localhost:1818/hero' }

Node.js v20.7.0 `

From cloud: `2023-11-25T23:35:42.619Z ERROR [hero-core\index] UnhandledError(fatal) { origin: 'uncaughtException', context: {}, sessionId: null, sessionName: undefined } Error: read ECONNRESET at TCP.onStreamRead (node:internal/stream_base_commons:217:20) { errno: -4077, code: 'ECONNRESET', syscall: 'read' } node:events:492 throw er; // Unhandled 'error' event ^

Error: read ECONNRESET at TCP.onStreamRead (node:internal/stream_base_commons:217:20) Emitted 'error' event on Socket instance at: at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -4077, code: 'ECONNRESET', syscall: 'read' }

Node.js v20.7.0 `

blakebyrnes commented 7 months ago

Hi @Allamaris0, sorry you're running into issues. Are you running your cloud on the same machine? Or is it remote? If remote, you need to provide the ip/port of your server. ShowChrome will only work on the machine where Cloud (and thus Chrome) are installed, and needs to have a GUI. If it's linux, for instance, it won't work without xvfb. If none of these are your issues, you mentioned "showChrome" doesn't work - does headless work?

Allamaris0 commented 7 months ago

Headless works. Cloud is running on the same machine. I work with phpstorm so in one terminal cloud is running and a script in the second. I have windows. I also had a problem when I had tried to set proxies

blakebyrnes commented 7 months ago

Are there more errors in the logs from cloud? Is this running in WSL? I wonder if that would cause issues with showing in headed.