selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Option for not resolving DNS (keeping hostname in URL) for remote connection ?

Open Remi-p opened this issue 9 years ago • 2 comments

Hi,

My company uses the PaaS Open Shift. So basically there are multiples DNS for the same IP address. The service distinguishes requests with the DNS in the message. I deployed a hub and a node with SeleniumHQ/docker-selenium, on the PaaS (Open Shift).

On the other hand, I found that Selenium has chosen to get and use the IP address of the server, for performance purposes (this commit for instance : 2b10d56c).

So, when I try to access the hub server, through the python library, the server refuses my requests. For instance with openshift :

WebDriverException: Message:
[...]
<h1>Application is not available</h1>
      <p>The application is currently not serving requests at this endpoint. It may not have been started or is still starting.</p>

Should an option be added somewhere, so that the hostname is kept ? Or did I missed it ?

I temporary (and in an ugly way) resolved the problem for my configuration, by changing the self._url = remote_server_addr of selenium/py/selenium/webdriver/remote/remote_connection.py into :

#self._url = remote_server_addr
self._url = "http://myaddr/wd/hub"

(yes it bypasses all the preceding processes)

I'm available to add any missing information, if needed.

Meta -

OS:
Debian Selenium Version:
(python) selenium==2.53.6 Browser: Selenium Hub

Selenium Hub Version:
Selenium build info: version: '3.4.0', revision: 'unknown'

Expected Behavior -

Connect to the hub with the URL.

Actual Behavior -

Connection fails, because direct messages to IP address are forbidden on the server.

Steps to reproduce -

Install a hub on a server, behind a firewall/proxy where connections to the IP are refused. Connect to the remote hub with the python library.

Edit : The trouble as I understood it :

                                              +--OpenShift PaaS---------------------------+
+Local debian machine-+                       |                                           |
|                     |                       |                       +----------------+  |
| +-----------------+ | hostname:80  +-OpenShift Routes :---------+   |Selenium Hub    |  |
| |Selenium modified+---------------->http://host:80 -> HubIP:4444+-->+Docker Container|  |
| |python library   | |              +----------------------------+   +----------------+  |
| +-----------------+ |                       |                               ^           |
|                     |                       |                               v           |
| +-----------------+ | IP_addr:80   \ /      |                       +----------------+  |
| |Selenium default +---------------->X       |                       |Selenium Node   |  |
| |python library   | |              / \      |                       |Docker Container|  |
| +-----------------+ |                       |                       +----------------+  |
+---------------------+                       +-------------------------------------------+

Remi-p avatar Jun 19 '17 17:06 Remi-p

@Remi-p You can make resolve-ip to false.

from selenium.webdriver.remote.remote_connection import RemoteConnection
hostname = "https://myhost.com/wd/hub"
executor = RemoteConnection(hostname, resolve_ip=False)
driver = webdriver.Remote(executor, capabilities)

mithunmo avatar Jul 15 '17 05:07 mithunmo

You're right it works, thanks !!

I'm using Robot Framework, so for Chrome the lines are :

!Open Remote Chrome through Selenium Hub
    [Arguments]    ${url}    ${selenium hub}
    ${desired capabilities}=    Evaluate    {'browserName': 'chrome'}
    ${executor}    Evaluate    sys.modules['selenium.webdriver'].remote.remote_connection.RemoteConnection("http://myhost.com/wd/hub", resolve_ip=False)    sys, selenium.webdriver
    Create Webdriver    Remote    command_executor=${executor}    desired_capabilities=${desired capabilities}
    Go To    ${url}

Remi-p avatar Jul 17 '17 15:07 Remi-p