Skip to content

Delayed connection attempts

Andrea Cardaci edited this page Nov 27, 2016 · 1 revision

It is not possible to detect when the remote instance is properly started and ready to accept connections. A workaround may be to perform delayed connection attempts until success.

const CDP = require('chrome-remote-interface');

(function connect() {
    console.log('Connecting...');
    CDP((client) => {
        console.log('Connected!');
        client.close();
    }).on('error', (err) => {
        setTimeout(connect, 1000);
    });
})();