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]: VNC viewer issue in Kubernetes with nginx ingress extra / in wss URL #2075

Closed
amardeep2006 opened this issue Dec 21, 2023 · 9 comments · Fixed by #2076 or SeleniumHQ/selenium#13353

Comments

@amardeep2006
Copy link
Contributor

amardeep2006 commented Dec 21, 2023

What happened?

I upgraded to latest helm chart version 0.26.3 and NoVNC sessions have stopped working.
The selenium test cases and UI works fine without issues. Only problem is with VNC sessions. I am not using any subpaths.
I am using https setup (automatic with sectigo tls) .

I see blank screen if I click on the video icon to see session.
Clue : Interestingly I see one extra forward slash (/) in wss url before session. In browser console logs.
I have double checked INGRESS_DOMAIN env variable does not contain this extra slash.

wss://abc.com//session/d5b0aa9f497f46d9f4d6d27bdb82a08c/se/vnc

image

Here is my value file.

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

global:
  seleniumGrid:
    # Image registry for all selenium components
    imageRegistry: myinternalrepo/selenium-grid
    # Image tag for all selenium components
    imageTag: "4.16.1"
    # Image tag for browser's nodes
    nodesImageTag: "4.16.1"
    # Image tag for browser's video recorder
    videoImageTag: "ffmpeg-6.1"
    # Pull secret for all components, can be overridden individually
    imagePullSecret: ""
    # Log level for all components. Possible values describe here: https://www.selenium.dev/documentation/grid/configuration/cli_options/#logging
    logLevel: INFO
isolateComponents: $ISOLATE_COMPONENTS
# Basic auth settings for Selenium Grid
basicAuth:
  # Enable or disable basic auth
  enabled: $BASIC_AUTH_ENABLED
autoscaling:
  enabled: $AUTOSCALING_ENABLED
  scalingType: $SCALING_TYPE
  # Options for KEDA scaled resources (keep only common options used for both ScaledJob and ScaledObject)
  scaledOptions:
    minReplicaCount: 0
    maxReplicaCount: $MAX_REPLICAS_COUNT
    pollingInterval: 10
customLabels: {"app-id": "selgrid", "app-tier": "application"}
ingress:
  # Name of ingress class to select which controller will implement ingress resource
  # Custom annotations for ingress resource
  annotations: {"cert-manager.io/cluster-issuer": "ci-0-acme-sectigo","nginx.ingress.kubernetes.io/proxy-connect-timeout": "600","nginx.ingress.kubernetes.io/proxy-read-timeout": "600","nginx.ingress.kubernetes.io/proxy-send-timeout": "600"}
  # Default host for the ingress resource
  hostname: $INGRESS_DOMAIN
  tls:
    - secretName: sel-grid-tls-secret
      hosts:
        - $INGRESS_DOMAIN
router:
  imagePullPolicy: Always
distributor:
  imagePullPolicy: Always  
eventBus:
  imagePullPolicy: Always
sessionMap:
  imagePullPolicy: Always
sessionQueue:
  imagePullPolicy: Always    
hub:
  imagePullPolicy: Always
  # Resources for container
  resources:
    requests:
      memory: "2Gi"
      cpu: "2"
    limits:
      memory: "8Gi"
      cpu: "4"
  extraEnvironmentVariables:
    - name: SE_JAVA_OPTS
      value: "-Xms1024m -Xmx8192m"
chromeNode:
  enabled: true
  replicas: $CHROME_NODE_REPLICAS
  terminationGracePeriodSeconds: 2700
  imagePullPolicy: Always
  # /dev/shm volume
  dshmVolumeSizeLimit: "2Gi"
  # Resources for chrome-node container
  resources:
    requests:
      memory: "1Gi"
      cpu: "1"
    limits:
      memory: "2Gi"
      cpu: "2"
  extraEnvironmentVariables: 
    # - name: "SE_VNC_NO_PASSWORD"
    #   value: "1"
    - name: "SE_VNC_VIEW_ONLY"
      value: "1"      
edgeNode:
  # Enable edge nodes
  enabled: true
  replicas: $MSEDGE_NODE_REPLICAS
  imagePullPolicy: Always
  # /dev/shm volume
  dshmVolumeSizeLimit: "2Gi"
  # Resources for edge-node container
  resources:
    requests:
      memory: "1Gi"
      cpu: "1"
    limits:
      memory: "2Gi"
      cpu: "2"
  extraEnvironmentVariables: 
    # - name: "SE_VNC_NO_PASSWORD"
    #   value: "1"
    - name: "SE_VNC_VIEW_ONLY"
      value: "1"         
firefoxNode:
  # Enable firefox nodes
  enabled: true
  replicas: "$FIREFOX_NODE_REPLICAS" 
  imagePullPolicy: Always
  # /dev/shm volume
  dshmVolumeSizeLimit: "2Gi"
  # Resources for firefox-node container
  resources:
    requests:
      memory: "1Gi"
      cpu: "1"
    limits:
      memory: "2Gi"
      cpu: "2"
  extraEnvironmentVariables: 
    # - name: "SE_VNC_NO_PASSWORD"
    #   value: "1"
    - name: "SE_VNC_VIEW_ONLY"
      value: "1"         
keda:
  image:
    keda:
      # -- Image name of KEDA operator
      repository: myinternalrepo/kedacore/keda
      # -- Image tag of KEDA operator. Optional, given app version of Helm chart is used by default
      tag: "2.12.1"
    metricsApiServer:
      # -- Image name of KEDA Metrics API Server
      repository: myinternalrepo/kedacore/keda-metrics-apiserver
      # -- Image tag of KEDA Metrics API Server. Optional, given app version of Helm chart is used by default
      tag: "2.12.1"
    webhooks:
      # -- Image name of KEDA admission-webhooks
      repository: myinternalrepo/kedacore/keda-admission-webhooks
      # -- Image tag of KEDA admission-webhooks . Optional, given app version of Helm chart is used by default
      tag: "2.12.1"
    # -- Image pullPolicy for all KEDA components
  podLabels:
    # -- Pod labels for KEDA operator
    keda: {"app-id": "selgrid", "app-tier": "application"}
    # -- Pod labels for KEDA Metrics Adapter
    metricsAdapter: {"app-id": "selgrid", "app-tier": "application"}
    # -- Pod labels for KEDA Admission webhooks
    webhooks: {"app-id": "selgrid", "app-tier": "application"}

Relevant log output

websock.js:231 WebSocket connection to 'wss://abc.com//session/d5b0aa9f497f46d9f4d6d27bdb82a08c/se/vnc' failed: Error during WebSocket handshake: Unexpected response code: 502

Operating System

Kubernetes

Docker Selenium version (image tag)

4.16.1

Selenium Grid chart version (chart version)

0.26.3

Copy link

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

@amardeep2006
Copy link
Contributor Author

Additional Troubleshooting : I tried following combinations

Selenium grid Chart version 0.26.3 with Selenium-Server 4.15.0 : The NoVNC works fine without issues.

Selenium grid Chart version 0.26.3 with Selenium-Server 4.16.1 : The NoVNC have issues and appends extra slash in url.

@amardeep2006 amardeep2006 changed the title [🐛 Bug]: VNC viewer issue in Kubernetes with nginx ingress [🐛 Bug]: VNC viewer issue in Kubernetes with nginx ingress extra / in wss URL Dec 21, 2023
@miguelsuddya
Copy link

I think the issue roots come from here
SeleniumHQ/selenium#13219.

this pull request was merged into trunk and delivered exactly in 4,16

@VietND96
Copy link
Member

VietND96 commented Dec 22, 2023

I can confirm the issue comes from the chart itself, due to change #2073, / added to SE_NODE_GRID_URL always
In normal cases, e.g I run standalone, without subpath, the VNC URL is constructed correctly

docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.16.1-20231219

Also, upstream needs a fix to handle trailing slash, so users no longer have to worry about the slash.
I will fix both soon.

@VietND96
Copy link
Member

A workaround I think will help you continue with 0.26.3, in chart, go to templates/_helpers.tpl (line 403), update it to

{{- $subPath := "" -}}

@amardeep2006
Copy link
Contributor Author

A workaround I think will help you continue with 0.26.3, in chart, go to templates/_helpers.tpl (line 403), update it to

{{- $subPath := "" -}}

I tried this workaround but unfortunately it did not seem to work. Still seeing extra / .

@VietND96
Copy link
Member

VietND96 commented Dec 22, 2023

More values need to be updated in background. Hence I have done the patch in chart 0.26.4

@amardeep2006
Copy link
Contributor Author

I am amazed by your work @VietND96 . I tested with 0.26.4 and issue is fixed. Really appreciate.

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 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants