Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: WSS support (Ruby) #13167

Closed
csgbn opened this issue Nov 17, 2023 · 11 comments
Closed

[🐛 Bug]: WSS support (Ruby) #13167

csgbn opened this issue Nov 17, 2023 · 11 comments
Labels
C-grid C-rb I-defect I-question Applied to questions. Issues should be closed and send the user to community resources. R-awaiting answer

Comments

@csgbn
Copy link

csgbn commented Nov 17, 2023

What happened?

This is a follow up on #12950

We are testing the language bindings against a distributed https grid with separate nodes from the hub in AWS. The grid supports both http and https.

One simple CDP smoke test is carried out with nodes started with --grid-url https://example.com (WSS) and another test with non secure web socket --grid-url http://example.com (WS)

Our grid and method is the same, we first verify that the CDP test works with WS then we test with WSS

Findings so far

Java - Works with both WS and WSS

C# - Works for WS but not for WSS and is being fixed #13131

Ruby - For Ruby we are seeing the same pattern as with C#, it works with WS but not WSS.

Before you asks for how are we deploying the grid and other specifics, please look into creating a test environment for testing a distributed https grid using WSS and CDP/BiDi and verify on your end, we could not find any reference that one exist and as for the case with C#, WSS path has never been tested...

We are supposed to test Python and Javascript CDP/BiDi next, please let us know if they do not yet have support for WSS CDP/BiDi, thanks.

How can we reproduce the issue?

# CDP test
require 'selenium-webdriver'
require 'selenium/devtools'

options = Selenium::WebDriver::Options.chrome(browser_version: '119', platform_name: 'linux', web_socket_url: true)

client = Selenium::WebDriver::Remote::Http::Default.new
client.read_timeout = 400 # seconds

driver = Selenium::WebDriver.for(:remote, :url => "https://example.com/wd/hub", :http_client => client, options: options)

begin
driver.manage.timeouts.implicit_wait = 60 # seconds
driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)

driver.devtools.network.enable
credentials = Base64.strict_encode64('admin:admin')
driver.devtools.network.set_extra_http_headers(headers: {authorization: "Basic #{credentials}"})
driver.get('https://the-internet.herokuapp.com/basic_auth')

ensure
driver.quit
end

Relevant log output

Capabilities:

{
  "acceptInsecureCerts": false,
  "browserName": "chrome",
  "browserVersion": "119.0.6045.105",
  "chrome": {
    "chromedriverVersion": "119.0.6045.105 (38c72552c5e15ba9b3117c0967a0fd105072d7c6-refs/branch-heads/6045@{#1103})",
    "userDataDir": "/tmp/.org.chromium.Chromium.QabCNy"
  },
  "fedcm:accounts": true,
  "goog:chromeOptions": {
    "debuggerAddress": "localhost:38293"
  },
  "networkConnectionEnabled": false,
  "pageLoadStrategy": "normal",
  "platformName": "linux",
  "proxy": {},
  "se:bidi": "wss://example.com/session/da9fb00f555e49b9a7cdfd1a3bf8f9db/se/bidi",
  "se:cdp": "wss://example.com/session/da9fb00f555e49b9a7cdfd1a3bf8f9db/se/cdp",
  "se:cdpVersion": "119.0.6045.105",
  "setWindowRect": true,
  "strictFileInteractability": false,
  "timeouts": {
    "implicit": 0,
    "pageLoad": 300000,
    "script": 30000
  },
  "unhandledPromptBehavior": "dismiss and notify",
  "webSocketUrl": "ws://localhost:29837/session/da9fb00f555e49b9a7cdfd1a3bf8f9db",
  "webauthn:extension:credBlob": true,
  "webauthn:extension:largeBlob": true,
  "webauthn:extension:minPinLength": true,
  "webauthn:extension:prf": true,
  "webauthn:virtualAuthenticators": true
}



error
Ruby32-x64/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.15.0/lib/selenium/webdriver/common/websocket_connection.rb:146:in `connect': SSL_connect returned=1 errno=0 peeraddr=76.9.274.42:443 state=error: unexpected eof while reading (OpenSSL::SSL::SSLError)

Operating System

Windows 11

Selenium version

4.15.0

What are the browser(s) and version(s) where you see this issue?

Chrome 119

What are the browser driver(s) and version(s) where you see this issue?

119.0.6045.105

Are you using Selenium Grid?

4.15.0

Copy link

@csgbn, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@csgbn
Copy link
Author

csgbn commented Dec 6, 2023

We can confirm the C# WSS path is fixed in 4.16.0, thanks!

@csgbn
Copy link
Author

csgbn commented Dec 7, 2023

Correction, fixed in 4.16.1.

Also tested Ruby with 4.16.0, however has the exact same issue as in 4.15.0 as described in this ticket.

@titusfortner
Copy link
Member

@p0deje did we discuss this issue somewhere else, it sounds familiar?

@p0deje
Copy link
Member

p0deje commented Dec 7, 2023

In Ruby we start secure socket connection as long as it's returned in connection URL -

@socket ||= if URI(@url).scheme == 'wss'
socket = TCPSocket.new(ws.host, ws.port)
socket = OpenSSL::SSL::SSLSocket.new(socket, OpenSSL::SSL::SSLContext.new)
socket.sync_close = true
socket.connect
socket
else
TCPSocket.new(ws.host, ws.port)
end
. I would need to investigate why it actually fails on Grid. I think it was @pujagani who added this logic - do you have WSS working in your setup?

@pujagani
Copy link
Contributor

pujagani commented Dec 8, 2023

In the past I have relied on using --self-signed-https true in the Grid. For some reason, that flag is present but throwing an error when used. Trying to look into it.

@pujagani
Copy link
Contributor

pujagani commented Dec 8, 2023

I have landed the fix. Using --self-signed-https should work now.

@p0deje
Copy link
Member

p0deje commented Dec 8, 2023

Thanks @pujagani!

I can now run Grid in SSL mode and I can see Ruby using WSS under the hood, but I cannot reproduce the issue:

java -jar bazel-bin/java/src/org/openqa/selenium/grid/selenium_server_deploy.jar standalone --self-signed-https
...
irb(main):003> options = Selenium::WebDriver::Options.chrome(web_socket_url: true)
=> #<Selenium::WebDriver::Chrome::Options:0x000000012fa44540
irb(main):005> driver = Selenium::WebDriver.for(:remote, :url => "https://192.168.1.34:4444", options: options)
=> #<Selenium::WebDriver::Remote::Driver:0x6270e210902b1bd2 browser=:chrome>
irb(main):010> driver.devtools
=>
#<Selenium::WebDriver::DevTools:0x000000010f9f8480
 @session_id="9B7BC116F8AB06C39D3C80510149EC61",
 @ws=
  #<Selenium::WebDriver::WebSocketConnection:0x000000010f9f82a0
   ...
   @url="wss://192.168.1.34:4444/session/3503fcf2569462fc1ecf3311c26580bf/se/cdp",    # WSS URL
   ...
irb(main):006> driver.devtools.network.enable
=> {"id"=>3, "result"=>{}, "sessionId"=>"9B7BC116F8AB06C39D3C80510149EC61"}
irb(main):007> credentials = Base64.strict_encode64('admin:admin')
=> "YWRtaW46YWRtaW4="
irb(main):008> driver.devtools.network.set_extra_http_headers(headers: {authorization: "Basic #{credentials}"})
irb(main):009> driver.get('https://the-internet.herokuapp.com/basic_auth')
=> nil

@csgbn Any idea what is different from your setup?

@titusfortner
Copy link
Member

closing as did not get a response. Adding links for asking questions below.

@titusfortner titusfortner added I-question Applied to questions. Issues should be closed and send the user to community resources. and removed needs-triaging labels Dec 31, 2023
Copy link

💬 Please ask questions at:

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-grid C-rb I-defect I-question Applied to questions. Issues should be closed and send the user to community resources. R-awaiting answer
Projects
None yet
Development

No branches or pull requests

4 participants