Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

headless-chrome: The response: 'Host header is specified and is not an IP address or localhost.' #65

Closed
Michael-Brooks opened this issue May 11, 2020 · 6 comments

Comments

@Michael-Brooks
Copy link

Michael-Brooks commented May 11, 2020

I'm using the headless-chrome service for running browser tests and the url in my app settings is set to "http://chrome:9222", but when I run my tests I get the error that's in the issue title. I've been searching around and apparently it's down to the Chrome version being used.

This issue OnetapInc/chromy#110 explains what's going on and I tried switching to the container/version they're using which stopped the error but gives me a new one.

Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.
Error code: 4
The response: 

I'm guessing it's using the correct container and port name now, but something in the service yaml file isn't set correctly which is why the response is now blank. Any help with this issue would be greatly appreciated.

@rfay
Copy link
Member

rfay commented May 11, 2020

@juban @isholgueras any thoughts on this?

@juban
Copy link
Contributor

juban commented May 13, 2020

@Michael-Brooks @rfay I'm not familiar with chromy, but perhaps you could try to install a headless chrome directly into the ddev web container using a custom Dockerfile and run your tests directly within the container ? Installation would go something like this:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb

@Michael-Brooks
Copy link
Author

Thanks @juban, I'll give that a go

@juban
Copy link
Contributor

juban commented May 15, 2020

@Michael-Brooks In case you are struggling to install chrome in the ddev web container, you can add the following Dockerfile into .ddev/web-build which will install the needed dependencies and the latest chrome version. If that's still not working with chromy, you could perhaps download an older version of chrome.

ARG BASE_IMAGE
FROM $BASE_IMAGE
RUN apt update
RUN apt -y install gconf-service libasound2 libatk1.0-0 libcairo2 libgconf-2-4 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libappindicator1 libnss3 xdg-utils libappindicator3-1 libdbusmenu-gtk3-4 libgbm1 libindicator3-7 libwayland-server0
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome*.deb

@Michael-Brooks
Copy link
Author

Oh sorry @juban, I think you misunderstood what I was trying to say. I was trying to use https://github.com/drud/ddev-contrib/blob/master/docker-compose-services/headless-chrome/docker-compose.chrome.yaml but ran into the error as titled.

I did a Google search to find that Chromy had the same issue and they used an earlier version of Chromy to fix. I then thought I would give Chromy a try with the version they used and received a blank page.

The headless chrome service linked above won't allow me to use an earlier version of Chrome since I think it always uses the latest.

I tried creating my own Dockerfile in web-build as suggested, but I can't seem to get it working on port 9222. If I add the below to the Dockerfile, then my ddev-router stops working.

ENTRYPOINT [ "google-chrome" ]
CMD [ "--headless", "--remote-debugging-port=9222" ]

@Michael-Brooks
Copy link
Author

I got it working #51 in the end. Thank you so much for trying to help, I really appreciate it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants