Code Monkey home page Code Monkey logo

Comments (4)

carranzpibisi avatar carranzpibisi commented on June 10, 2024

I just found the solution, could you add it to the readme if it is the correct solution.

  $firefoxOptions = new FirefoxOptions();
  $firefoxProfile = new FirefoxProfile();

  $firefoxProfile->setPreference('network.proxy.type', 1);
  $firefoxProfile->setPreference('network.proxy.socks', [IP]);
  $firefoxProfile->setPreference('network.proxy.socks_port', [PORT]);
  $firefoxProfile->setPreference('network.proxy.http', [IP]);
  $firefoxProfile->setPreference('network.proxy.http_port', [PORT]);

  $firefoxOptions->setProfile($firefoxProfile);
  
  $this->client = Client::createFirefoxClient('/usr/local/bin/geckodriver', null,
      [
          'capabilities' => ['moz:firefoxOptions' => $firefoxOptions]
      ]
  );

from panther.

julianlaibach avatar julianlaibach commented on June 10, 2024

Thank you for your suggestion. Does this still works for you? I am encountering an Error when using those Settings:

Process unexpectedly closed with status 1

If i uncomment the Proxy it works fine. Also when running geckodriver --log trace i cannot see any issues.

from panther.

carranzpibisi avatar carranzpibisi commented on June 10, 2024

Hello @julianlaibach,
Let's see if I can help you.

This is my complete working code:

$options = [
    'connection_timeout_in_ms' => 10000, // 10s
    'request_timeout_in_ms' => 60000,    // 60s
    'port' => 4444,
    'capabilities' => [ 'acceptInsecureCerts' => true ]
];
 
if ($use_proxy) {       
    $firefox_options = new FirefoxOptions();
    $firefox_profile = new FirefoxProfile();
    
    $firefox_profile->setPreference('network.proxy.type', 1);
    $firefox_profile->setPreference('network.proxy.socks', 'XXX.XXX.XXX.XXXX');
    $firefox_profile->setPreference('network.proxy.socks_port', 'XXXX');
    $firefox_profile->setPreference('network.proxy.socks_version', 5);
    
    $firefox_options->addArguments(['--headless']);
    $firefox_options->addArguments(['--window-size=1200,1100']);
    
    $firefox_options->setProfile($firefox_profile);
    $capabilities = DesiredCapabilities::firefox();
    $capabilities->setCapability(FirefoxOptions::CAPABILITY, $firefox_options);
    
    $options['capabilities'] = array_merge($options['capabilities'], [FirefoxOptions::CAPABILITY => $firefox_options]);
}

Client::createFirefoxClient('/usr/local/bin/geckodriver', null, $options);

The error you’re encountering, I’ve also reproduced it, but for different reasons, even when trying to upgrade my Ubuntu.
Here’s my machine context:

  • Ubuntu 20.04 (In Ubuntu 22.04, I get a ‘Process unexpectedly closed with status 1’ error without using a proxy.)
  • PHP 7.4
  • Architecture: x86 and aarch64 (arm) --> This affects compatible firefox
  • Geckodriver v0.32.0
  • Firefox: firefox-109(x86) and firefox-125 (arm)

With this configuration, the mentioned code has worked for me. I must mention that upgrading Ubuntu, Geckodriver, and Firefox results in different errors or sometimes doesn’t work at all.

Honestly, configuring Panther has been challenging for me too. It’s quite sensitive, and sudden version changes can cause issues. Debugging it has taken many hours of testing.

I hope I’ve helped you in some way, even if it’s just by providing context. It depends a lot on each case; you have to try different configurations, there’s no other way.

from panther.

julianlaibach avatar julianlaibach commented on June 10, 2024

Thank you for your Response! Its a bit strange to be honest but i think i maybe found a good alternative:

$client = Client::createFirefoxClient(null,
    [
        '--no-sandbox',
        '--headless',
        '--allow-insecure-certificates'
    ],
    [
        'capabilities' => [
            'proxy' => [
                'proxyType' => 'manual',
                'httpProxy' => "localhost:8080", // <- from mitmproxy
                'sslProxy' => "localhost:8080", // <- from mitmproxy
            ],
            'acceptInsecureCerts' => true
        ]
    ]
);

If your Proxy needs Authentication you need to use mitmproxy like this:

mitmproxy --quiet --mode upstream:http://yourproxy:yourproxyport --upstream-auth username:password

Hope this helps you too as i can currently see no Issues when up or downgrading the Versions!

from panther.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.