Curl error thrown for http POST to /session

6.4k Views Asked by At

I installed Laravel Dusk for website testing. I tried every solution on Stackoverflow regarding this problem but nothing worked.

I need to run browser headless because I'm running tests on my Linux server.

Current version of chromedriver-linux is:

 ./vendor/laravel/dusk/bin/chromedriver-linux --v
ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429})

Current version of Chromium is:

 chromium-browser --version --no-sandbox
Chromium 90.0.4430.93 snap

When I run Dusk I get error:

Operation timed out after 30001 milliseconds with 0 bytes received
Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","platformName":"linux","goog:chromeOptions":{"args":["--headless","--disable-gpu","--no-sandbox"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"linux","chromeOptions":{"args":["--headless","--disable-gpu","--no-sandbox"]}}}

Is there any way to resolve this? I tried by adding arguments "--headless","--disable-gpu","--no-sandbox" but unfortunately it is not working.

1

There are 1 best solutions below

1
On

friend!

I assume you are on Windows host with Homestead (Windows 10, Homestead 10 and Laravel 8). If not, I am not sure this answer will help. But this just helped me, literally, a few minutes ago, so I feel obliged.

  1. Dusk appears not like Chromium and desires a full Chrome. So lets install it:
cd ~
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

This will download the latest stable google chrome and install it.

  1. Do make sure that you got your project's vendor/laravel/dusk/bin/ folder is executable, as the docs suggest. So, in the root of your project:
chmod -R 0755 vendor/laravel/dusk/bin/
  1. Make sure you got the latest chromium-driver installed:
php artisan dusk:chrome-driver --detect

3.1. If it will give you hard time (cannot rename, cannot move files, yada-yada) - it is probably because you have the driver already running, so exit Homestead and just

vagrant reload

return back to homestead and repeat 3 above.

  1. Make sure you are able to curl your APP_URL. Let's say it is laravel.app:
curl http://laravel.app

If not, check /etc/hosts, you expect to see something like 127.0.0.1 laravel.app - following our assumption about the URL. This is normally set by Homestead itself, when you provision a new site.

Voila.

php artisan dusk

was successful.

That fixed it for me.

I have spent exorbitant amount of time which could have been saved by a single line in docs "If you are running Homestead on Windows, make sure to install Google Chrome"

Happy coding!