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

Node WebSocket not working with sub-path option #13407

Merged
merged 4 commits into from
Jan 9, 2024
Merged

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Jan 8, 2024

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

[java] Update subPath for ProxyNodeWebsockets

Motivation and Context

Fix issue #13393 - WebSocket at ws://ip:port/selenium-grid/sessions/{ID}/se/vnc with selenium-grid is the sub-path


Some info on the fix

  • In NodeOptions added method getSubPath() to extract the subPath from config grid-url / hub (in [node] section)
  • In ProxyNodeWebsockets, subPath is removed from the request URI before matching UrlTemplate

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fffd05c) 58.07% compared to head (e5c4dfb) 58.07%.

❗ Current head e5c4dfb differs from pull request most recent head 4c0a3b6. Consider uploading reports for the commit 4c0a3b6 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #13407   +/-   ##
=======================================
  Coverage   58.07%   58.07%           
=======================================
  Files          88       88           
  Lines        5340     5340           
  Branches      224      224           
=======================================
  Hits         3101     3101           
  Misses       2015     2015           
  Partials      224      224           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VietND96 VietND96 force-pushed the trunk branch 2 times, most recently from 7d864d4 to cb27bd1 Compare January 8, 2024 05:19
Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Node should not need changes, the Router/Hub should be in charge of forwarding the WebSocket message to the Node and that is it. The client does not have direct access to Nodes, which is why we should not change the Nodes at all.

@VietND96 VietND96 force-pushed the trunk branch 2 times, most recently from b42111a to 1c9ca5c Compare January 8, 2024 18:06
@VietND96
Copy link
Member Author

VietND96 commented Jan 8, 2024

The Node should not need changes, the Router/Hub should be in charge of forwarding the WebSocket message to the Node and that is it. The client does not have direct access to Nodes, which is why we should not change the Nodes at all.

@diemol Yes, the client does not have direct access to Nodes. The change is only for Router/Hub forwarding to ProxyNodeWebsockets.
The Router/Hub forwarding request e.g /subPath/session/{id}/se/vnc. In ProxyNodeWebsockets there are some UrlTemplate matching to open particular Ws, and the problem is there. When matching e.g req /subPath/session/{id}/se/vnc vs template /session/{id}/se/vnc it returned not match, which caused the Ws not open correctly.
In NodeOptions, at least grid-url or hub is required always for Node register to Router/Hub, user can pass the Grid URL within subPath from the config. In Node, only there is getGridSubPath() to extract the subPath from Router/Hub URL and set it to ProxyNodeWebsockets for matching UrlTemplate as well as construct the URLs for se:vnc, cdp, bidi, fwd in session capabilities, which is used to establish Ws
I have renamed the method to getGridSubPath, hope that avoid the confusion that we are trying to allow users to set subPath for Nodes to access directly from outside.

@diemol
Copy link
Member

diemol commented Jan 9, 2024

The Node should not need changes, the Router/Hub should be in charge of forwarding the WebSocket message to the Node and that is it. The client does not have direct access to Nodes, which is why we should not change the Nodes at all.

@diemol Yes, the client does not have direct access to Nodes. The change is only for Router/Hub forwarding to ProxyNodeWebsockets. The Router/Hub forwarding request e.g /subPath/session/{id}/se/vnc. In ProxyNodeWebsockets there are some UrlTemplate matching to open particular Ws, and the problem is there. When matching e.g req /subPath/session/{id}/se/vnc vs template /session/{id}/se/vnc it returned not match, which caused the Ws not open correctly. In NodeOptions, at least grid-url or hub is required always for Node register to Router/Hub, user can pass the Grid URL within subPath from the config. In Node, only there is getGridSubPath() to extract the subPath from Router/Hub URL and set it to ProxyNodeWebsockets for matching UrlTemplate as well as construct the URLs for se:vnc, cdp, bidi, fwd in session capabilities, which is used to establish Ws I have renamed the method to getGridSubPath, hope that avoid the confusion that we are trying to allow users to set subPath for Nodes to access directly from outside.

Understood, thank you. It makes sense.

@diemol diemol merged commit e7d902e into SeleniumHQ:trunk Jan 9, 2024
39 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: WebSocket Path Not Working with Selenium Grid --sub-path Option
4 participants