chrome-launcher
chrome-launcher copied to clipboard
isDebuggerReady() net.createConnection ECONNREFUSED error in AWS ec2 instance
Hello
I was trying to run Rendertron using npm start in an AWS ec2 instance to avoid the docker container performance penalty.
then I got this error after npm start
[email protected] start /home/ec2-user/rendertron node src/main.js { Error: connect ECONNREFUSED 127.0.0.1:33465 at Object._errnoException (util.js:1026:11) at _exceptionWithHostPort (util.js:1049:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 33465 } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: node src/main.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The root of the problem was the isDebuggerReady() {} in chrome launcher. It seems that net.createConnection can never properly create a connection.
However, everything is running fine locally.
any ideas how to fix it?
Reproduction Steps
-
start an AWS ec2 instance with AMI
-
connect to the ec2 instance
-
install git
sudo yum install git
-
pull rendertron repo
-
git clone https://github.com/GoogleChrome/rendertron.git
-
install chrome
sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
-
cd into rendertron folder
cd rendertron
-
npm install
-
npm start
Tried work arounds
- comment out
yield this.waitUntilReady();
inchrome-launcher.js
in thespawnProcess
function. Rendertron was able to run, but if I try to render a page, it will give the following error.
Uncaught exception { Error: connect ECONNREFUSED 127.0.0.1:38585 at Object._errnoException (util.js:1026:11) at _exceptionWithHostPort (util.js:1049:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 38585 }
- Increase the pollInterval to 50000ms. And simply the same result. net.createConnection() simply throws ECONNREFUSED error as soon as it tries to create a connection.
Thanks!
@hekod777 rendertron is using an older version of chrome-launcher (~0.3 instead of latest 0.8) which has a few mitigations that might help (though it looks like you've already tried increasing the poll interval).
Can you confirm that Chrome is actually starting successfully through other means? i.e. you can connect to the port from another process after you increase the poll interval. It's possible it's silently failing to start.
@patrickhulce I think chrome was actually running because I have the following line in the logs
ChromeLauncher Chrome running with pid 5782 on port 46423.
and I have upgrade chrome-launcher to 0.8+. but still the same error.
The debugger is where pain is.
I modified isDebuggerReady(){} to see the more information
isDebuggerReady() {
return new Promise((resolve, reject) => {
const client = net.createConnection(this.port);
console.log('the client is ' + client);
console.log('the port is ' + this.port);
client.once('error', err => {
console.log('is debugger ready error ' + err);
this.cleanup(client);
reject(err);
});
client.once('connect', () => {
this.cleanup(client);
resolve();
});
});
}
This is what I saw
1
Chrome LauncherWaiting for browser...
the client is [object Object]
the port is 33371
is debugger ready error Error: connect ECONNREFUSED 127.0.0.1:33371
2
Chrome LauncherWaiting for browser.....
the client is [object Object]
the port is 33371
is debugger ready error Error: connect ECONNREFUSED 127.0.0.1:33371
3
Chrome LauncherWaiting for browser.......
the client is [object Object]
the port is 33371
is debugger ready error Error: connect ECONNREFUSED 127.0.0.1:33371
PS: I also tried using red hat 7.4 linux instead of Amazon Linux AMI. but still the same error