Maany has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I'm running strawberry perl and I can't control Chrome from perl, it connects to Chrome and opens a new "about:blank" tab but then gives an error

can't connect without knowing the port?! 0 at C:/Strawberry/perl/site/lib/Chrome/DevToolsProtocol.pm line 317.

I launched Chrome with --remote-debugging-port-9222, and set the options in perl code

my $mech = WWW::Mechanize::Chrome->new(port => 9222);

but on $TRACE I get below.

2021/06/06 10:12:39 Spawning $VAR1 = [ 'C:\\Users\\Maany\\AppData\\Local\\Google\\Chrome\\Applicati +on\\chrome.exe', '--v=0', '--remote-debugging-port=0', '--enable-automation', '--no-first-run', '--mute-audio', '--no-zygote', '--no-sandbox', '--safebrowsing-disable-auto-update', '--disable-background-networking', '--disable-breakpad', '--disable-client-side-phishing-detection', '--disable-component-update', '--disable-hang-monitor', '--disable-prompt-on-repost', '--disable-sync', '--disable-translate', '--disable-web-resources', '--disable-default-apps', '--disable-infobars', '--disable-popup-blocking', '--disable-gpu', '--disable-save-password-bubble', 'about:blank' ];

so port is not set, have tried :

#!perl use strict; use WWW::Mechanize::Chrome; $ENV{WWW_MECHANIZE_CHROME_CONNECTION_STYLE}='pipe'; my $mech = WWW::Mechanize::Chrome::->new();


but I got below error

Only websocket communication is supported on MSWin32, not 'pipe'

any help please ?

Replies are listed 'Best First'.
Re: can't connect without knowing the port?! 0 www::mechanize::chrome
by Corion (Patriarch) on Jun 06, 2021 at 08:32 UTC

    This error happens when you already have an instance of Chrome running. If you want to connect to that running instance and it crashes like that, this is a bug - I need to investigate that.

Re: can't connect without knowing the port?! 0 www::mechanize::chrome
by Corion (Patriarch) on Jul 09, 2021 at 19:51 UTC

    I've fixed another round of these errors - v0.67 is now on CPAN and should fix that.