Comments (4)
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.
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.
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.
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)
- TransportException
- Problem with detect driver HOT 3
- submit form isn't submitting
- Unable to run even a basic test HOT 2
- Can we add an option to not start a geckodriver listener?
- Not compatible with phpunit 10.4.0 HOT 6
- Failed to read marionette port error when using createFirefoxClient()
- Tag new release for Symfony 7 HOT 4
- <bootstrap> instead of <extension> expected in phpunit 10.4 configuration HOT 3
- TypeError is thrown when calling Crawler::html() HOT 1
- Error: Call to undefined method Symfony\Component\Panther\Client::assertSelectorIsNotVisible()
- Custom binary path to Firefox
- Chrome client crontab
- Selecting a radio button with value "0" is not possible if another element is pre-selected HOT 1
- Errors starting the webserver get hidden
- How to wait for all images to be loaded? HOT 2
- Docs improvement to help on how resize browser window
- CSS/JS not loading while working with AssetMapper
- Running chrome in headed mode - help needed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panther.