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

Support http proxies for websockets #16326

Merged
merged 11 commits into from
Dec 13, 2024
Merged

Support http proxies for websockets #16326

merged 11 commits into from
Dec 13, 2024

Conversation

jakekaplan
Copy link
Contributor

@jakekaplan jakekaplan commented Dec 10, 2024

Closes: #15474

This PR introduces a wrapper class WebsocketProxyConnect to support websocket connections through an http proxy. It does this by passing the proxy negotiation off to python-socks, getting a fully connected socket and then passing that open socket back to websockets for the rest of the process.

It supports the standard environment variables HTTP_PROXY and HTTPS_PROXY, which is what we would expect a client to set currently for using a proxy with regular http requests.

This PR also adds an integration test setup with a simple api and a squid proxy, to ensure it is working properly. I had difficultly getting this to work entirely in pytest, so it has it's own directory of config + a github action. Looking for feedback if this is a fine approach.

@github-actions github-actions bot added the upstream dependency An upstream issue caused by a bug in one of our dependencies label Dec 10, 2024
Copy link

codspeed-hq bot commented Dec 10, 2024

CodSpeed Performance Report

Merging #16326 will not alter performance

Comparing websocket-proxy-support (1086417) with main (b2faff3)

Summary

✅ 3 untouched benchmarks

@jakekaplan jakekaplan force-pushed the websocket-proxy-support branch from 71cb046 to b299653 Compare December 12, 2024 05:08
@github-actions github-actions bot added the enhancement An improvement of an existing feature label Dec 12, 2024
@jakekaplan jakekaplan marked this pull request as ready for review December 12, 2024 05:25
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

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

The integration test is awesome! I have a couple of comments, but overall this is looking great!

src/prefect/utilities/proxy.py Outdated Show resolved Hide resolved
src/prefect/utilities/proxy.py Outdated Show resolved Hide resolved
scripts/proxy-test/README.md Show resolved Hide resolved
src/prefect/utilities/proxy.py Outdated Show resolved Hide resolved
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

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

LGTM!

@jakekaplan jakekaplan merged commit 40590a5 into main Dec 13, 2024
41 checks passed
@jakekaplan jakekaplan deleted the websocket-proxy-support branch December 13, 2024 00:33
EmilRex pushed a commit that referenced this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature upstream dependency An upstream issue caused by a bug in one of our dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support proxy when sending/receiving events over websocket
2 participants