phantombuster / nickjs

Web scraping library made by the Phantombuster team. Modern, simple & works on all websites. (Deprecated)
https://nickjs.org
ISC License
500 stars 48 forks source link

could not list chrome tabs: Error: connect ECONNREFUSED 127.0.0.1:9222 #61

Open msaus opened 5 years ago

msaus commented 5 years ago

I often get this error after running for while. Also, when I get this error, I have to restart the node process.

Do you have any suggestion for this?

Google Chrome 70.0.3538.110

paps commented 5 years ago

Maybe you have too many open tabs? Are you closing the tabs you're not using?

"After running for a while" means about how long?

msaus commented 5 years ago

I always close the tab. After crawling 10 web site, I get this error message.

paps commented 5 years ago

Does it happen on other websites? Is the website so heavy that maybe you have no memory left? What have to tried? Thx

msaus commented 5 years ago

No it dose not happened on other website. Then, my server has 8G memory and the memory is always 3G left as well as swap not being happened.

Also, now the error happens sometimes, not often. This is bit weird for me.

msaus commented 5 years ago

Possibly, we wait and see how things go.

paps commented 5 years ago

Maybe start NickJS in debug mode (debug: true in constructor) and we can see some output showing us what's wrong

allgrowsm commented 4 years ago

Sorry for late reply.

I got following errors.

2019-12-12 12:28 : CHROME STDERR: [1212/122838.971585:ERROR:socket_posix.cc(145)] bind() failed: address already in use (98)
DevTools listening on ws://[::1]:9222/devtools/browser/98a1a41d-1cb9-4a6c-97e8-ca7cdb590840
2019-12-12 12:28 : > It took 103ms to start and connect to Chrome (1 tries)
2019-12-12 12:28 : Error: could not list chrome tabs: Error: connect ECONNREFUSED 127.0.0.1:9222
2019-12-12 12:28 : CHROME STDERR: 
DevTools listening on ws://127.0.0.1:9222/devtools/browser/833f02dc-74f5-484f-930e-5e5b4881d26b
2019-12-12 12:28 : > It took 256ms to start and connect to Chrome (2 tries)
paps commented 4 years ago

Well, it looks like the 9222 port is already in use on your system. Maybe you already have Chrome running with debug enabled, even though NickJS tries to start a new one?

A fix would be to disable debug mode on this other Chrome instance, or at least change the port (which is one of the cmd line options of Chrome).

allgrowsm commented 4 years ago

@paps Thanks for your reply.

I finally found the reason why I am getting these errors every time I access to my crawler.

I use pm2 for load balancing node process and port collision occurs because of multiple node process.

Dose nickJS has options for the port number?

paps commented 4 years ago

Oh ok, I see. That means your node instances are started with debugging enabled right?

You can use additionalChildOptions (array of command line parameters) to change how Chrome is started in NickJS (this only works in the latest version, please update if necessary). But I'm afraid you will not be able to change the port number this way, this is one of the hardcoded options of NickJS. You will need to free port 9222 somehow. Or submit a PR :)

allgrowsm commented 4 years ago

@paps Thanks for that. I will take a look at that option and see if I can change port number as well as submitting PR :)

allgrowsm commented 4 years ago

@paps Hi there, I just had quick look at your source code and I understand what the hardcoded options mean. This sort of option should be optionally set when it is constructed or after initialized. I will have a look at this issue after the long holiday. Happy Holiday :)