SeleniumHQ / docker-selenium

Provides a simple way to run Selenium Grid with Chrome, Firefox, and Edge using Docker, making it easier to perform browser automation
http://www.selenium.dev/docker-selenium/
Other
7.96k stars 2.51k forks source link

[🐛 Bug]: Websocket's don't work with subPath #2051

Closed Doofus100500 closed 9 months ago

Doofus100500 commented 11 months ago

What happened?

I'm running tests through Playwright, and everything works until I specify a subPath and ingress.path different from "/". In my case, it's /staging. The node returns an incorrect path:

wss://grid.test.com/session/9a359f0273ad1e079266cdb63e348167/se/cdp. 

This is the same as without subPath. I even tried passing SE_NODE_GRID_URL in the environment:

- name: SE_NODE_GRID_URL
  value: "https://grid.test.com/staging"

But the result doesn't change; it feels like the path is being truncated somewhere.

Command used to start Selenium Grid with Docker (or Kubernetes)

helm

Relevant log output

SELENIUM_REMOTE_URL=https://grid.test.com/staging/ SELENIUM_REMOTE_CAPABILITIES='{"browserName": "chrome","browserVersion": "119.0","platformName": "linux"}' DEBUG=pw:api,pw:protocol,pw:browser* npx playwright test

- <selenium> using additional capabilities "{"browserName": "chrome","browserVersion": "119.0","platformName": "linux"}"
      - <selenium> connecting to https://grid.test.com/staging/
      - <selenium> connected to sessionId=9a359f0273ad1e079266cdb63e348167
      - <selenium> using selenium v4
      - <selenium> retrieved endpoint wss://grid.test.com/session/9a359f0273ad1e079266cdb63e348167/se/cdp for sessionId=9a359f0273ad1e079266cdb63e348167

Operating System

k8s

Docker Selenium version (tag or chart version)

0.26.0

github-actions[bot] commented 11 months ago

@Doofus100500, 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!

diemol commented 11 months ago

You need to upgrade to use the latest.

Doofus100500 commented 11 months ago

Update all components and connection string changed, but i'm getting new errors: Playwright:

      - <selenium> using additional capabilities "{"browserName": "chrome","browserVersion": "120.0","platformName": "linux"}"
      - <selenium> connecting to https://grid.test.com/staging/
      - <selenium> connected to sessionId=295ceecc4f985e5293fb43e0ccbb48ad
      - <selenium> using selenium v4
      - <selenium> retrieved endpoint wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp for sessionId=295ceecc4f985e5293fb43e0ccbb48ad
      - <ws connecting> wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp
      - <ws unexpected response> wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp 502 Bad Gateway
    <html>
    <head><title>502 Bad Gateway</title></head>
    <body>
    <center><h1>502 Bad Gateway</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

      - <ws error> wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp error WebSocket was closed before the connection was established
      - <ws connect error> wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp WebSocket was closed before the connection was established
      - <ws disconnected> wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp code=1006 reason=
      - <selenium> disconnecting from sessionId=295ceecc4f985e5293fb43e0ccbb48ad
      - <selenium> disconnected from sessionId=295ceecc4f985e5293fb43e0ccbb48ad

Selenium node:

2023-12-07 13:27:02,352 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2023-12-07 13:27:02,355 INFO RPC interface 'supervisor' initialized
2023-12-07 13:27:02,355 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2023-12-07 13:27:02,355 INFO supervisord started with pid 8
2023-12-07 13:27:03,360 INFO spawned: 'xvfb' with pid 9
2023-12-07 13:27:03,364 INFO spawned: 'vnc' with pid 10
2023-12-07 13:27:03,367 INFO spawned: 'novnc' with pid 11
2023-12-07 13:27:03,371 INFO spawned: 'selenium-node' with pid 12
2023-12-07 13:27:03,529 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Appending Selenium node session timeout via SE_OPTS:  --session-timeout 300
Generating Selenium Config
Configuring server...
Setting up SE_NODE_HOST...
Setting up SE_NODE_PORT...
Tracing is enabled
Classpath will be enriched with these external jars :  --ext /external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-exporter-otlp/1.31.0/opentelemetry-exporter-otlp-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-exporter-jaeger/1.31.0/opentelemetry-exporter-jaeger-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/grpc/grpc-netty/1.59.0/grpc-netty-1.59.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk-trace/1.31.0/opentelemetry-sdk-trace-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk-metrics/1.31.0/opentelemetry-sdk-metrics-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk-logs/1.31.0/opentelemetry-sdk-logs-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-exporter-otlp-common/1.31.0/opentelemetry-exporter-otlp-common-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-exporter-sender-okhttp/1.31.0/opentelemetry-exporter-sender-okhttp-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk-extension-autoconfigure-spi/1.31.0/opentelemetry-sdk-extension-autoconfigure-spi-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk/1.31.0/opentelemetry-sdk-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-exporter-common/1.31.0/opentelemetry-exporter-common-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/com/fasterxml/jackson/jr/jackson-jr-objects/2.15.2/jackson-jr-objects-2.15.2.jar:/external_jars/https/repo1.maven.org/maven2/io/grpc/grpc-core/1.59.0/grpc-core-1.59.0.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.97.Final/netty-codec-http2-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-handler-proxy/4.1.97.Final/netty-handler-proxy-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/com/google/guava/guava/32.0.1-android/guava-32.0.1-android.jar:/external_jars/https/repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.20.0/error_prone_annotations-2.20.0.jar:/external_jars/https/repo1.maven.org/maven2/io/perfmark/perfmark-api/0.26.0/perfmark-api-0.26.0.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.97.Final/netty-transport-native-unix-common-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-api/1.31.0/opentelemetry-api-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-sdk-common/1.31.0/opentelemetry-sdk-common-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-extension-incubator/1.31.0-alpha/opentelemetry-extension-incubator-1.31.0-alpha.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-api-events/1.31.0-alpha/opentelemetry-api-events-1.31.0-alpha.jar:/external_jars/https/repo1.maven.org/maven2/com/squareup/okhttp3/okhttp/4.11.0/okhttp-4.11.0.jar:/external_jars/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar:/external_jars/https/repo1.maven.org/maven2/io/grpc/grpc-api/1.59.0/grpc-api-1.59.0.jar:/external_jars/https/repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar:/external_jars/https/repo1.maven.org/maven2/com/google/android/annotations/4.1.1.4/annotations-4.1.1.4.jar:/external_jars/https/repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations/1.23/animal-sniffer-annotations-1.23.jar:/external_jars/https/repo1.maven.org/maven2/io/grpc/grpc-context/1.59.0/grpc-context-1.59.0.jar:/external_jars/https/repo1.maven.org/maven2/io/grpc/grpc-util/1.59.0/grpc-util-1.59.0.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-common/4.1.97.Final/netty-common-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-buffer/4.1.97.Final/netty-buffer-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-transport/4.1.97.Final/netty-transport-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-codec/4.1.97.Final/netty-codec-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-handler/4.1.97.Final/netty-handler-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.97.Final/netty-codec-http-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-codec-socks/4.1.97.Final/netty-codec-socks-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/external_jars/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/external_jars/https/repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/external_jars/https/repo1.maven.org/maven2/org/checkerframework/checker-qual/3.33.0/checker-qual-3.33.0.jar:/external_jars/https/repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/2.8/j2objc-annotations-2.8.jar:/external_jars/https/repo1.maven.org/maven2/io/opentelemetry/opentelemetry-context/1.31.0/opentelemetry-context-1.31.0.jar:/external_jars/https/repo1.maven.org/maven2/com/squareup/okio/okio/3.2.0/okio-3.2.0.jar:/external_jars/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.6.20/kotlin-stdlib-1.6.20.jar:/external_jars/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.20/kotlin-stdlib-jdk8-1.6.20.jar:/external_jars/https/repo1.maven.org/maven2/io/netty/netty-resolver/4.1.97.Final/netty-resolver-4.1.97.Final.jar:/external_jars/https/repo1.maven.org/maven2/com/squareup/okio/okio-jvm/3.2.0/okio-jvm-3.2.0.jar:/external_jars/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.6.20/kotlin-stdlib-common-1.6.20.jar:/external_jars/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar:/external_jars/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.20/kotlin-stdlib-jdk7-1.6.20.jar
Selenium Grid Node configuration: 
[events]
publish = "tcp://selenium-event-bus:4442"
subscribe = "tcp://selenium-event-bus:4443"

[node]
grid-url = "https://grid.test.com/staging"
session-timeout = "300"
override-max-sessions = false
detect-drivers = false
drain-after-session-count = 0
max-sessions = 1

[[node.driver-configuration]]
display-name = "chrome"
stereotype = '{"browserName": "chrome", "browserVersion": "120.0", "platformName": "Linux", "goog:chromeOptions": {"binary": "/usr/bin/google-chrome"}}'
max-sessions = 1

Starting Selenium Grid Node...
2023-12-07 13:27:04,541 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-12-07 13:27:04,541 INFO success: vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-12-07 13:27:04,541 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
13:27:07.052 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
13:27:07.238 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
13:27:09.567 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-event-bus:4442 and tcp://selenium-event-bus:4443
13:27:09.857 INFO [UnboundZmqEventBus.<init>] - Sockets created
13:27:10.862 INFO [UnboundZmqEventBus.<init>] - Event bus ready
13:27:11.437 INFO [NodeServer.createHandlers] - Reporting self as: http://10.233.125.106:5555
13:27:11.540 INFO [NodeOptions.getSessionFactories] - Detected 1 available processors
13:27:11.750 INFO [NodeOptions.report] - Adding chrome for {"browserName": "chrome","browserVersion": "120.0","goog:chromeOptions": {"binary": "\u002fusr\u002fbin\u002fgoogle-chrome"},"platformName": "linux","se:noVncPort": 7900,"se:vncEnabled": true} 1 times
13:27:11.825 INFO [Node.<init>] - Binding additional locator mechanisms: relative
13:27:12.566 INFO [NodeServer$1.start] - Starting registration process for Node http://10.233.125.106:5555
13:27:12.626 INFO [NodeServer.execute] - Started Selenium node 4.16.0 (revision 15400459dd*): http://10.233.125.106:5555
13:27:12.658 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
13:27:13.847 INFO [NodeServer.lambda$createHandlers$2] - Node has been added
13:27:14.846 INFO [GlobalOpenTelemetry.maybeAutoConfigureAndSetGlobal] - AutoConfiguredOpenTelemetrySdk found on classpath but automatic configuration is disabled. To enable, run your JVM with -Dotel.java.global-autoconfigure.enabled=true
13:27:18.134 INFO [LocalNode.newSession] - Session created by the Node. Id: 295ceecc4f985e5293fb43e0ccbb48ad, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome-headless-shell, browserVersion: 120.0.6099.62, chrome: {chromedriverVersion: 120.0.6099.62 (93ab19d804d4..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:18847}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: wss://grid.test...., se:cdpVersion: 120.0.6099.62, se:vnc: wss://grid.test...., se:vncEnabled: true, se:vncLocalAddress: ws://10.233.125.106:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
13:27:18.536 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:127)
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:52)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at org.openqa.selenium.netty.server.WebSocketUpgradeHandler.channelRead(WebSocketUpgradeHandler.java:98)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:91)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)
13:27:18.565 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:127)
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:52)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at org.openqa.selenium.netty.server.WebSocketUpgradeHandler.channelRead(WebSocketUpgradeHandler.java:98)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:91)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)
13:27:18.587 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:127)
    at org.openqa.selenium.netty.server.RequestConverter.channelRead0(RequestConverter.java:52)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at org.openqa.selenium.netty.server.WebSocketUpgradeHandler.channelRead(WebSocketUpgradeHandler.java:98)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:91)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)
13:27:19.054 INFO [SessionSlot.stop] - Stopping session 295ceecc4f985e5293fb43e0ccbb48ad
13:28:10.106 INFO [LocalNode.drain] - Firing node drain complete message
13:28:11.116 INFO [NodeServer.lambda$createHandlers$3] - Shutting down
2023-12-07 13:28:11,602 INFO exited: selenium-node (exit status 0; expected)
2023-12-07 13:28:11,602 WARN received SIGINT indicating exit request
2023-12-07 13:28:11,602 INFO waiting for xvfb, vnc, novnc to die
2023-12-07 13:28:13,606 INFO stopped: novnc (terminated by SIGTERM)
2023-12-07 13:28:14,607 INFO stopped: vnc (terminated by SIGTERM)
2023-12-07 13:28:14,608 INFO waiting for xvfb to die
Trapped SIGTERM/SIGINT/x so shutting down supervisord...
2023-12-07 13:28:15,609 INFO stopped: xvfb (terminated by SIGTERM)
Shutdown complete
diemol commented 11 months ago

Is there a way to reproduce that using Selenium code?

diemol commented 11 months ago

502 Bad Gateway does not come from the Grid. Maybe you have something on top of the Grid? Nginx?

VietND96 commented 11 months ago

Hi @Doofus100500, as the comment I put here https://github.com/SeleniumHQ/selenium/issues/12791#issuecomment-1847592555. Extra config needed, and in the chart, I handled via PR #2053 I saw you give ENV var with URL https://. Can you put only http://, or use chart 0.26.1 and remove it (since default it is http if ingress.tls empty)

It means in ENV variable, --grid-url use http:// and from outside we access via https://. That is the behavior I observed in NoVNC, not sure it could be same with CDP

Doofus100500 commented 10 months ago

Hi @vietnd96, With CDP, the situation is as follows: the node provides this address (wss://grid.test.com/staging/session/295ceecc4f985e5293fb43e0ccbb48ad/se/cdp) to the Playwright client, so the client attempts to connect to this address from my machine, but it fails to establish a connection.

diemol commented 10 months ago

Does it fail when you use Selenium?

Doofus100500 commented 10 months ago

Does it fail when you use Selenium?

Not sure how to reproduce it using Selenium, but I think the outcome will be the same because the address provided in the end is not accessible.

VietND96 commented 10 months ago

Let me try a reproduce this CDP connection. But it doesn't work with SE_NODE_GRID_URL=http://grid.test.com/staging also?

Doofus100500 commented 10 months ago

Yes, it doesn't work with SE_NODE_GRID_URL=http://grid.test.com/staging because my nginx drop http connections(because HTTP connections are insecure):

      - <ws unexpected response> ws://grid.test.com/staging/session/06d271def3d45f1384171bb3326c29c2/se/cdp 301 Moved Permanently
    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>
diemol commented 10 months ago

Yes, it doesn't work with SE_NODE_GRID_URL=http://grid.test.com/staging because my nginx drop http connections(because HTTP connections are insecure):

      - <ws unexpected response> ws://grid.test.com/staging/session/06d271def3d45f1384171bb3326c29c2/se/cdp 301 Moved Permanently
    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

But that's an issue with that nginx config.

Regarding reproducing with Selenium, you can use any of the examples shown in the docs. I am asking for a way to reproduce with Selenium because this sub-path feature has been there for a while, and I have not seen any reports. So it might be your nginx config or a problem while following redirects in Playwright.

Doofus100500 commented 10 months ago

I changed the settings in nginx, now when SE_NODE_GRID_URL=http://grid.test.com/staging, the behavior is the same as in this comment: https://github.com/SeleniumHQ/docker-selenium/issues/2051#issuecomment-1845354673

Doofus100500 commented 10 months ago

Just in case, I'll write down how to reproduce my issue with Playwright:

npm init playwright@latest npx playwright test --project chromium SELENIUM_REMOTE_URL=https://grid.test.com/staging SELENIUM_REMOTE_CAPABILITIES='{"browserName": "chrome"}' DEBUG=pw:api,pw:protocol,pw:browser* npx playwright test

By the way, WebSocket connections still don't work for me with VNC

websock.js:231 WebSocket connection to 'wss://grid.test.com/staging/session/5c8cb441719e81d97d5440b12500eb6e/se/vnc' failed: 
value @ websock.js:231
rfb.js:686 WebSocket on-error event
value @ rfb.js:686
rfb.js:941 Failed when connecting: Connection closed (code: 1006)
value @ rfb.js:941
VietND96 commented 10 months ago

@Doofus100500, I have set up a Selenium Grid (4.16.1) and a Playwright (1.40.1) test to reproduce your case. When I am using the default Chart to deploy and test. I can see the issue below

SELENIUM_REMOTE_URL=http://aws.ndviet.org/selenium SELENIUM_REMOTE_CAPABILITIES='{"browserName": "chrome"}' DEBUG=pw:api,pw:protocol,pw:browser* npx playwright test

Running 1 test using 1 worker
  pw:api => selectors.setTestIdAttribute started +0ms
  pw:api => browserType.launch started +7ms
  pw:browser <selenium> using additional capabilities "{"browserName": "chrome"}" +0ms
  pw:browser <selenium> connecting to http://aws.ndviet.org/selenium/ +0ms
  pw:api <= selectors.setTestIdAttribute succeeded +13ms
  pw:browser <selenium> connected to sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd +10s
  pw:browser <selenium> using selenium v4 +1ms
  pw:browser <selenium> retrieved endpoint ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp for sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd +0ms
  pw:browser <ws connecting> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp +2ms
  pw:browser <ws error> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp error getaddrinfo ENOTFOUND selenium-router.default +6ms
  pw:browser <ws connect error> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp getaddrinfo ENOTFOUND selenium-router.default +0ms
  pw:browser <ws disconnected> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp code=1006 reason= +0ms
  pw:browser <selenium> disconnecting from sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd +0ms
  pw:browser <selenium> disconnected from sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd +678ms
  pw:api <= browserType.launch failed +11s
F

  1) tests/recorder.login.test.ts:2:5 ?? test ??????????????????????????????????????????????????????????????????????????????????????????????????????????????

    Error: browserType.launch: WebSocket error: getaddrinfo ENOTFOUND selenium-router.default
    Call log:
      - <selenium> using additional capabilities "{"browserName": "chrome"}"
      - <selenium> connecting to http://aws.ndviet.org/selenium/
      - <selenium> connected to sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd
      - <selenium> using selenium v4
      - <selenium> retrieved endpoint ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp for sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd
      - <ws connecting> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp
      - <ws error> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp error getaddrinfo ENOTFOUND selenium-router.default
      - <ws connect error> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp getaddrinfo ENOTFOUND selenium-router.default
      - <ws disconnected> ws://selenium-router.default:4444/selenium/session/7d86b5d1fb9cb5ccf2c54ef8404190bd/se/cdp code=1006 reason=
      - <selenium> disconnecting from sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd
      - <selenium> disconnected from sessionId=7d86b5d1fb9cb5ccf2c54ef8404190bd

This is one issue with Chart value. By default, the value is rendered for SE_NODE_GRID_URL: http://selenium-router.{{ Namespace }}:4444/{{ subPath }} This URL is only accessible in the K8s cluster. If the test runs outside and connects to this URL, it cannot establish a connection.

Updated: By default ingress.hostname is empty, hence that local URL is rendered. When hostname is set correctly

ingress:
  hostname: aws.ndviet.org

SE_NODE_GRID_URL now is a public URL can connect. After that, I can execute the test successfully with below logs

SELENIUM_REMOTE_URL=http://aws.ndviet.org/selenium SELENIUM_REMOTE_CAPABILITIES='{"browserName": "chrome"}' DEBUG=pw:api,pw:protocol,pw:browser* npx playwright test
  pw:api => selectors.setTestIdAttribute started +0ms
  pw:api => browserType.launch started +7ms
  pw:browser <selenium> using additional capabilities "{"browserName": "chrome"}" +0ms
  pw:browser <selenium> connecting to http://aws.ndviet.org/selenium/ +0ms
  pw:api <= selectors.setTestIdAttribute succeeded +13ms
  pw:browser <selenium> connected to sessionId=b4f39647a36388c94530937cca67aa93 +11s
  pw:browser <selenium> using selenium v4 +0ms
  pw:browser <selenium> retrieved endpoint ws://aws.ndviet.org/selenium/session/b4f39647a36388c94530937cca67aa93/se/cdp for sessionId=b4f39647a36388c94530937cca67aa93 +0ms
  pw:browser <ws connecting> ws://aws.ndviet.org/selenium/session/b4f39647a36388c94530937cca67aa93/se/cdp +2ms
  pw:browser <ws connected> ws://aws.ndviet.org/selenium/session/b4f39647a36388c94530937cca67aa93/se/cdp +730ms
  pw:protocol SEND ?? {"id":1,"method":"Browser.getVersion"} +0ms
  pw:protocol ?? RECV {"id":1,"result":{"protocolVersion":"1.3","product":"Chrome/120.0.6099.71","revision":"@9729082fe6174c0a371fc66501f5efc5d69d3d2b","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","jsVersion":"12.0.267.8"}} +285ms
  pw:protocol SEND ?? {"id":2,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true}} +2ms

So, I belive that something in the ingress config leads to the error. I don't have much experience in ingress, I just have simple configs as below

  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/app-root: /selenium
    nginx.ingress.kubernetes.io/auth-keepalive-timeout: "3600"
    nginx.ingress.kubernetes.io/client-body-buffer-size: 512M
    nginx.ingress.kubernetes.io/proxy-buffer-size: 512M
    nginx.ingress.kubernetes.io/proxy-buffering: "on"
    nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-next-upstream-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-request-buffering: "on"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: aws.ndviet.org
      http:
        paths:
          - backend:
              service:
                name: 'selenium-router'
                port:
                  number: 4444
            path: /selenium(/|$)(.*)
            pathType: ImplementationSpecific

Regarding NoVNC, it could be a delay that troubleshoot via #2045 that had a workaround in #2058 will be released new image tag soon

VietND96 commented 10 months ago

@Doofus100500, are you able to proceed with your test on top of latest chart version 0.26.2?

Doofus100500 commented 10 months ago

@vietnd96, Hi, I've updated the chart version, also disconnected from nginx and now only use Ingress (https://github.com/kubernetes/ingress-nginx/tree/main). As a result, the error looks like this:

  pw:api => selectors.setTestIdAttribute started +0ms
  pw:api => browserType.launch started +3ms
  pw:api <= selectors.setTestIdAttribute succeeded +5ms
  pw:browser <selenium> using additional capabilities "{"browserName": "chrome","browserVersion": "120.0","platformName": "linux"}" +0ms
  pw:browser <selenium> connecting to https://grid.test.com/staging/ +0ms
  pw:browser <selenium> connected to sessionId=b9c87d9f705777de1f6ba48b20571b6b +3s
  pw:browser <selenium> using selenium v4 +0ms
  pw:browser <selenium> retrieved endpoint ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp for sessionId=b9c87d9f705777de1f6ba48b20571b6b +0ms
  pw:browser <ws connecting> ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp +29ms
  pw:browser <ws unexpected response> ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp 308 Permanent Redirect
  pw:browser <html>
  pw:browser <head><title>308 Permanent Redirect</title></head>
  pw:browser <body>
  pw:browser <center><h1>308 Permanent Redirect</h1></center>
  pw:browser <hr><center>nginx</center>
  pw:browser </body>
  pw:browser </html>
  pw:browser  +479ms
  pw:browser <ws error> ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp error WebSocket was closed before the connection was established +1ms
  pw:browser <ws connect error> ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp WebSocket was closed before the connection was established +0ms
  pw:browser <ws disconnected> ws://grid.test.com/staging/session/b9c87d9f705777de1f6ba48b20571b6b/se/cdp code=1006 reason= +1ms
  pw:browser <selenium> disconnecting from sessionId=b9c87d9f705777de1f6ba48b20571b6b +0ms
  pw:browser <selenium> disconnected from sessionId=b9c87d9f705777de1f6ba48b20571b6b +474ms
  pw:api <= browserType.launch failed +4s

more likely because of cycle redirect: http->https->http

And when I'm changing SE_NODE_GRID_URL to https in configmap for node:

  pw:api => selectors.setTestIdAttribute started +0ms
  pw:api => browserType.launch started +2ms
  pw:api <= selectors.setTestIdAttribute succeeded +6ms
  pw:browser <selenium> using additional capabilities "{"browserName": "chrome","browserVersion": "120.0","platformName": "linux"}" +0ms
  pw:browser <selenium> connecting to https://grid.test.com/staging/ +0ms
  pw:browser <selenium> connected to sessionId=7b96eae5979d518d7c18abcc54a5817f +2s
  pw:browser <selenium> using selenium v4 +0ms
  pw:browser <selenium> retrieved endpoint wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp for sessionId=7b96eae5979d518d7c18abcc54a5817f +0ms
  pw:browser <ws connecting> wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp +26ms
  pw:browser <ws unexpected response> wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp 502 Bad Gateway
  pw:browser <html>
  pw:browser <head><title>502 Bad Gateway</title></head>
  pw:browser <body>
  pw:browser <center><h1>502 Bad Gateway</h1></center>
  pw:browser <hr><center>nginx</center>
  pw:browser </body>
  pw:browser </html>
  pw:browser  +626ms
  pw:browser <ws error> wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp error WebSocket was closed before the connection was established +1ms
  pw:browser <ws connect error> wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp WebSocket was closed before the connection was established +0ms
  pw:browser <ws disconnected> wss://grid.test.com/staging/session/7b96eae5979d518d7c18abcc54a5817f/se/cdp code=1006 reason= +1ms
  pw:browser <selenium> disconnecting from sessionId=7b96eae5979d518d7c18abcc54a5817f +0ms
  pw:browser <selenium> disconnected from sessionId=7b96eae5979d518d7c18abcc54a5817f +913ms
  pw:api <= browserType.launch failed +3s
VietND96 commented 10 months ago

@Doofus100500, not sure any missing from my end but I could not reproduce the issue. Chart version 0.26.3, configs YAML that I used for deployment https://github.com/SeleniumHQ/docker-selenium/blob/trunk/tests/charts/refValues/sample-aws.yaml Tested instance http://aws.ndviet.org/selenium Test source https://github.com/ndviet/test-playwright-ts Can you take a look any clue from that info?

Doofus100500 commented 10 months ago

@vietnd96 From what I've managed to understand, it turns out that there is a redirect to HTTPS in my Ingress, and I cannot remove it. That's why I am encountering "308 Permanent Redirect" errors. But the most interesting part is that as soon as I deploy Selenium without a subPath, everything works over HTTPS:

  pw:api => selectors.setTestIdAttribute started +0ms
  pw:api => browserType.launch started +3ms
  pw:api <= selectors.setTestIdAttribute succeeded +6ms
  pw:browser <selenium> using additional capabilities "{"browserName": "chrome","browserVersion": "120.0","platformName": "linux"}" +0ms
  pw:browser <selenium> connecting to https://grid.test.com/ +0ms
  pw:browser <selenium> connected to sessionId=ea8467ea06015b8bab2135cf14f4d679 +4s
  pw:browser <selenium> using selenium v4 +0ms
  pw:browser <selenium> retrieved endpoint wss://grid.test.com/session/ea8467ea06015b8bab2135cf14f4d679/se/cdp for sessionId=ea8467ea06015b8bab2135cf14f4d679 +1ms
  pw:browser <ws connecting> wss://grid.test.com/session/ea8467ea06015b8bab2135cf14f4d679/se/cdp +29ms
  pw:browser <ws connected> wss://grid.test.com/session/ea8467ea06015b8bab2135cf14f4d679/se/cdp +1s
  pw:protocol SEND ► {"id":1,"method":"Browser.getVersion"} +0ms
  pw:protocol ◀ RECV {"id":1,"result":{"protocolVersion":"1.3","product":"HeadlessChrome/120.0.6099.109","revision":"@3419140ab665596f21b385ce136419fde0924272","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/120.0.6099.109 Safari/537.36","jsVersion":"12.0.267.10"}} +88ms
  pw:protocol SEND ► {"id":2,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true}} +1ms
  pw:protocol SEND ► {"id":3,"method":"Browser.setDownloadBehavior","params":{"behavior":"allowAndName","downloadPath":"/var/folders/vm/8wcd_k2952d_llc8rxxt4nym0000gn/T/playwright-artifacts-dq0eBb","eventsEnabled":true}} +1ms
  pw:protocol ◀ RECV {"method":"Target.attachedToTarget","params":{"sessionId":"FCDBB4736BF6700909B8BC34DD480E29","targetInfo":{"targetId":"7A4ACD340D359FBD37750019660FCD3A","type":"page","title":"data:,","url":"data:,","attached":true,"canAccessOpener":false,"browserContextId":"72A452EE8AA726C4752FE75233B0DB61"},"waitingForDebugger":false}} +69ms
  pw:protocol SEND ► {"id":4,"method":"Page.enable","sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +3ms
  pw:protocol SEND ► {"id":5,"method":"Page.getFrameTree","sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +1ms
  pw:protocol SEND ► {"id":6,"method":"Log.enable","params":{},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":7,"method":"Page.setLifecycleEventsEnabled","params":{"enabled":true},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":8,"method":"Runtime.enable","params":{},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":9,"method":"Page.addScriptToEvaluateOnNewDocument","params":{"source":"","worldName":"__playwright_utility_world__"},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":10,"method":"Network.enable","sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":11,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":12,"method":"Emulation.setFocusEmulationEnabled","params":{"enabled":true},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":13,"method":"Page.setFontFamilies","params":{"fontFamilies":{"standard":"Times New Roman","fixed":"Monospace","serif":"Times New Roman","sansSerif":"Arial","cursive":"Comic Sans MS","fantasy":"Impact"}},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +1ms
  pw:protocol SEND ► {"id":14,"method":"Emulation.setEmulatedMedia","params":{"media":"","features":[{"name":"prefers-color-scheme","value":"light"},{"name":"prefers-reduced-motion","value":"no-preference"},{"name":"forced-colors","value":"none"}]},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol SEND ► {"id":15,"method":"Runtime.runIfWaitingForDebugger","sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +0ms
  pw:protocol ◀ RECV {"id":2,"result":{}} +2ms
  pw:protocol SEND ► {"id":16,"method":"Target.getTargetInfo"} +0ms
  pw:protocol ◀ RECV {"id":3,"result":{}} +0ms
  pw:protocol ◀ RECV {"id":4,"result":{},"sessionId":"FCDBB4736BF6700909B8BC34DD480E29"} +432ms
SE_NODE_GRID_URL: https://grid.test.com

SELENIUM_REMOTE_URL=https://grid.test.com
SELENIUM_REMOTE_CAPABILITIES={"browserName": "chrome","browserVersion": "120.0","platformName": "linux"}
DEBUG=pw:api,pw:protocol,pw:browser*

Have you tried using HTTPS?

VietND96 commented 10 months ago

I have not tried using HTTPS yet. However, via #2080 I will try.

more likely because of cycle redirect: http->https->http

After #2080 I guess we can enable SSL passthrough (HTTPS traffic from client -> ingress -> grid server).

VietND96 commented 9 months ago

@Doofus100500, if have time, can you please use nightly chart to have a test on WebSocket of NoVNC? - https://github.com/SeleniumHQ/docker-selenium/tree/trunk/charts/selenium-grid#installing-the-nightly-chart

Doofus100500 commented 9 months ago

This is awesome! After I changed http to https in SE_NODE_GRID_URL in the ConfigMap, everything started working: both noVNC and the Playwright test through wss. I'm looking forward to these changes in the main release. Huge thanks to you, @vietnd96!!!!

VietND96 commented 9 months ago

@Doofus100500, thank you for your feedback! I will mark this ticket as completed. The main release 4.17.0 will be introduced early next week. Updated: the root cause is fixed on upstream https://github.com/SeleniumHQ/selenium/pull/13407

github-actions[bot] commented 8 months ago

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.