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

Send host and port in Host header #1193

Closed
vania-pooh opened this issue Mar 18, 2022 · 19 comments
Closed

Send host and port in Host header #1193

vania-pooh opened this issue Mar 18, 2022 · 19 comments
Milestone

Comments

@vania-pooh
Copy link
Member

See mozilla/geckodriver#1935.

@ruescar
Copy link

ruescar commented Jun 16, 2022

@vania-pooh You may want to look at this at some point, now that geckodriver 0.31.0 was released
https://github.com/mozilla/geckodriver/releases/tag/v0.31.0
and hopefully #1142 can be fixed so we can continue using the latest driver available.

@vania-pooh
Copy link
Member Author

vania-pooh commented Jun 16, 2022

@ruescar will it work with e.g. Chromedriver? Currently we set just localhost.

@ruescar
Copy link

ruescar commented Jun 16, 2022

@vania-pooh If you could provide some build with the change I can test it against all browsers and channels.

@vania-pooh vania-pooh added this to the 1.10.8 milestone Jun 17, 2022
@vania-pooh
Copy link
Member Author

@ruescar checked this should work against Chrome:

vania-pooh:~/$ docker run -d --name browser -p 4444:4444 --privileged browsers/chrome:101.0
47bce07120d91d81948983c7f8db551a16c195d2f0ee63aef286dc1329ef998b
vania-pooh:~/$ docker exec -it browser hostname -f
47bce07120d9
vania-pooh:~/$ curl -vvv -H 'Content-Type: application/json' -H 'Host: 47bce07120d9:4444' --data '{"capabilities": {"alwaysMatch": {"browserName": "chrome"}}}' http://localhost:4444/session
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 4444 (#0)
> POST /session HTTP/1.1
> Host: 47bce07120d9:4444
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 60
>
* upload completely sent off: 60 out of 60 bytes
< HTTP/1.1 200 OK
< Content-Length:752
< Content-Type:application/json; charset=utf-8
< cache-control:no-cache
<
* Connection #0 to host localhost left intact
{"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"101.0.4951.54","chrome":{"chromedriverVersion":"101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904})","userDataDir":"/tmp/.com.google.Chrome.u254TN"},"goog:chromeOptions":{"debuggerAddress":"localhost:43505"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"linux","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"e2e3cc5b8ee73439eefaa753902cc44d"}}* Closing connection 0

@ruescar
Copy link

ruescar commented Jun 22, 2022

Thanks for the update @vania-pooh although I guess the main parts to test would be when using Selenoid grid (which uses random port for each browser container) or when running selenoid-container-tests where the Host header would need to be set in Selenium request via proxy...?

@vania-pooh
Copy link
Member Author

@ruescar we will obviously set the same Host header but using container hostname and port instead. I don't think there is some difference.

vania-pooh added a commit that referenced this issue Jun 25, 2022
Using host and port in Host header in container mode (related to #1193)
@vania-pooh
Copy link
Member Author

Seems to work. Already available in aerokube/selenoid:latest.

@ruescar
Copy link

ruescar commented Jun 29, 2022

@vania-pooh aerokube/selenoid:latest exits on startup:
standard_init_linux.go:228: exec user process caused: no such file or directory

@vania-pooh
Copy link
Member Author

@ruescar yes, fixed.

@ruescar
Copy link

ruescar commented Jun 30, 2022

@vania-pooh I've built an image with Firefox 101.0.1+build1-0ubuntu0.20.04.1 and geckodriver 0.31.0 and used with aerokube/selenoid:latest, but when run some test, the Selenium session still fails. Here are the logs:

2022-06-30T08:26:38.743603497Z 20
2022-06-30T08:26:38.774014475Z Waiting X server...
2022-06-30T08:26:38.921713971Z Waiting X server...
2022-06-30T08:26:38.929946604Z Logging to: /dev/null
2022-06-30T08:26:39.038783739Z Waiting X server...
2022-06-30T08:26:39.141957696Z Waiting X server...
2022-06-30T08:26:39.283741516Z Waiting X server...
2022-06-30T08:26:39.414780984Z 
2022-06-30T08:26:39.414793190Z  --- x11vnc loop: 1 ---
2022-06-30T08:26:39.414796462Z 
2022-06-30T08:26:39.428118349Z 2022/06/30 08:26:39 [-] [INIT] [Loading configuration files...]
2022-06-30T08:26:39.428330769Z 2022/06/30 08:26:39 [-] [INIT] [Loaded configuration from /tmp/browsers.json]
2022-06-30T08:26:39.429691982Z 2022/06/30 08:26:39 [-] [INIT] [Timezone: UTC]
2022-06-30T08:26:39.429762752Z 2022/06/30 08:26:39 [-] [INIT] [Listening on :4444]
2022-06-30T08:26:39.488077404Z 2022/06/30 08:26:39 [-] [NEW_REQUEST] [unknown] [172.17.0.2]
2022-06-30T08:26:39.488090165Z 2022/06/30 08:26:39 [-] [NEW_REQUEST_ACCEPTED] [unknown] [172.17.0.2]
2022-06-30T08:26:39.488093414Z 2022/06/30 08:26:39 [0] [LOCATING_SERVICE] [firefox] []
2022-06-30T08:26:39.488096547Z 2022/06/30 08:26:39 [-] [DEFAULT_VERSION] [Using default version: 101.0]
2022-06-30T08:26:39.488099815Z 2022/06/30 08:26:39 [0] [USING_DRIVER] [firefox] [101.0]
2022-06-30T08:26:39.488102756Z 2022/06/30 08:26:39 [0] [ALLOCATING_PORT]
2022-06-30T08:26:39.488105642Z 2022/06/30 08:26:39 [0] [ALLOCATED_PORT] [34971]
2022-06-30T08:26:39.488109135Z 2022/06/30 08:26:39 [0] [STARTING_PROCESS] [[/usr/bin/geckodriver --log debug --port=34971]]
2022-06-30T08:26:39.494780135Z 1656577599494	geckodriver	INFO	Listening on 127.0.0.1:34971
2022-06-30T08:26:39.546507401Z 2022/06/30 08:26:39 [0] [PROCESS_STARTED] [84] [0.06s]
2022-06-30T08:26:39.546522199Z 2022/06/30 08:26:39 [0] [PROXY_TO] [http://127.0.0.1:34971]
2022-06-30T08:26:39.546639123Z 2022/06/30 08:26:39 [0] [SESSION_ATTEMPTED] [http://127.0.0.1:34971] [1]
2022-06-30T08:26:39.546932289Z 1656577599546	webdriver::server	WARN	Rejected request with Host header localhost, allowed values are [localhost:34971]
2022-06-30T08:26:39.547046872Z 2022/06/30 08:26:39 [0] [SESSION_FAILED] [http://127.0.0.1:34971] [500 Internal Server Error]
2022-06-30T08:26:39.547054938Z 2022/06/30 08:26:39 [0] [TERMINATING_PROCESS] [84]
2022-06-30T08:26:39.547969703Z 2022/06/30 08:26:39 [0] [TERMINATED_PROCESS] [84] [0.00s]

@vania-pooh
Copy link
Member Author

@ruescar added one more change to make this work with drivers too.

@ruescar
Copy link

ruescar commented Jul 1, 2022

@vania-pooh Unfortunately I'm still getting the same error after the change.

@vania-pooh
Copy link
Member Author

@ruescar will test myself and get back.

@vania-pooh
Copy link
Member Author

@ruescar built Selenoid binary from latest source code. Checked with Firefox 102.0 and geckodriver 0.31.0. It works.

@vania-pooh
Copy link
Member Author

@ruescar please check one more and if it works, we will release.

@ruescar
Copy link

ruescar commented Jul 11, 2022

@vania-pooh Still not working for me when running selenoid-container-tests on a Mac against a local grid using aerokube/selenoid:latest and an image built with Firefox 102.0+build2-0ubuntu0.20.04.1 and geckodriver 0.31.0
mvn clean test -Dgrid.connection.url=http://localhost:4444/wd/hub -Dgrid.browser.name=firefox -Dgrid.browser.version=102.0

2022/07/11 09:36:09 [333] [SESSION_ATTEMPTED] [http://172.17.0.4:4444/wd/hub] [1]
2022/07/11 09:36:09 [333] [SESSION_FAILED] [http://172.17.0.4:4444/wd/hub] [500 Internal Server Error]

In other tests run in Linux machine, I get more verbose Selenoid logs:

2022-07-11T09:00:44.885397866Z 20
2022-07-11T09:00:44.906272606Z Waiting X server...
2022-07-11T09:00:45.070491750Z Waiting X server...
2022-07-11T09:00:45.072745270Z Logging to: /dev/null
2022-07-11T09:00:45.192970472Z Waiting X server...
2022-07-11T09:00:45.297457098Z Waiting X server...
2022-07-11T09:00:45.428844090Z 
2022-07-11T09:00:45.428873406Z  --- x11vnc loop: 1 ---
2022-07-11T09:00:45.428877247Z 
2022-07-11T09:00:45.428908426Z 2022/07/11 09:00:45 [-] [INIT] [Loading configuration files...]
2022-07-11T09:00:45.429215519Z 2022/07/11 09:00:45 [-] [INIT] [Loaded configuration from /tmp/browsers.json]
2022-07-11T09:00:45.429391729Z 2022/07/11 09:00:45 [-] [INIT] [Timezone: UTC]
2022-07-11T09:00:45.429420029Z 2022/07/11 09:00:45 [-] [INIT] [Listening on :4444]
2022-07-11T09:00:45.432968756Z 2022/07/11 09:00:45 [-] [NEW_REQUEST] [unknown] [172.17.0.2]
2022-07-11T09:00:45.432993248Z 2022/07/11 09:00:45 [-] [NEW_REQUEST_ACCEPTED] [unknown] [172.17.0.2]
2022-07-11T09:00:45.433583494Z 2022/07/11 09:00:45 [0] [LOCATING_SERVICE] [firefox] []
2022-07-11T09:00:45.433600594Z 2022/07/11 09:00:45 [-] [DEFAULT_VERSION] [Using default version: 102.0]
2022-07-11T09:00:45.433604451Z 2022/07/11 09:00:45 [0] [USING_DRIVER] [firefox] [102.0]
2022-07-11T09:00:45.433610640Z 2022/07/11 09:00:45 [0] [ALLOCATING_PORT]
2022-07-11T09:00:45.433917252Z 2022/07/11 09:00:45 [0] [ALLOCATED_PORT] [38377]
2022-07-11T09:00:45.433957867Z 2022/07/11 09:00:45 [0] [STARTING_PROCESS] [[/usr/bin/geckodriver --log debug --port=38377]]
2022-07-11T09:00:45.438402811Z 1657530045438	geckodriver	INFO	Listening on 127.0.0.1:38377
2022-07-11T09:00:45.490750994Z 1657530045489	webdriver::server	WARN	Rejected request with Host header localhost, allowed values are [localhost:38377]
2022-07-11T09:00:45.490810732Z 2022/07/11 09:00:45 [0] [PROCESS_STARTED] [81] [0.06s]
2022-07-11T09:00:45.490814948Z 2022/07/11 09:00:45 [0] [PROXY_TO] [http://127.0.0.1:38377]
2022-07-11T09:00:45.490817994Z 2022/07/11 09:00:45 [0] [SESSION_ATTEMPTED] [http://127.0.0.1:38377] [1]
2022-07-11T09:00:45.490821081Z 2022/07/11 09:00:45 [0] [SESSION_FAILED] [http://127.0.0.1:38377] [500 Internal Server Error]
2022-07-11T09:00:45.490823835Z 2022/07/11 09:00:45 [0] [TERMINATING_PROCESS] [81]
2022-07-11T09:00:45.492835186Z 2022/07/11 09:00:45 [0] [TERMINATED_PROCESS] [81] [0.00s]

@vania-pooh
Copy link
Member Author

@ruescar I think you just need to put to your image not Selenoid 1.10.7 but a binary compiled from latest source code. Once we release 1.10.8 - we'll be building new images using this version.

@ruescar
Copy link

ruescar commented Jul 12, 2022

@vania-pooh I did as you suggested and everything seems to work, including selenoid-container-tests.

Screenshot 2022-07-12 at 10 45 13
Screenshot 2022-07-12 at 11 01 20

@vania-pooh
Copy link
Member Author

Released in https://github.com/aerokube/selenoid/releases/tag/1.10.8.

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

No branches or pull requests

2 participants