-
Notifications
You must be signed in to change notification settings - Fork 135
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
Proxy support for smee client #194
Comments
I need this feature to be able to use smee in our environment. Would love to see it become reality ❤️ |
You can pass in your own custom fetch wrapper. NodeJS doesn't support Proxies out of the box with the Fetch API currently import { fetch as undiciFetch, ProxyAgent } from 'undici';
import SmeeClient from "smee-client";
const myFetch = (url, options) => {
return undiciFetch(url, {
...options,
dispatcher: new ProxyAgent(<your_proxy_url>)
})
}
const smee = new SmeeClient({
source: 'https://smee.io/abc123',
target: 'http://localhost:3000/events',
logger: console,
fetch: myFetch
}) This should be added to the README |
where are we meant to pass the custom fetch wrapper to? smee.js? i tried the previous solution and ended up with a sea of errors. |
Yes. That is what is indicated in the code example I shared
Those packages are probably not compatible with the native Fetch API available in Node and instead use the Node HTTP API |
Actually the examply is not quite the recommended way by undici. You would use setGlobalDispatcher to set the proxy agent globally. Also there is EnvProxyAgent, which can handle the HTTP_PROXY and HTTPS_PROXY env variables. I have to look up if it is enabled by default now on node.js, but that was the desired behavior. |
Undici probably updated since then, but my solution is backwards compatible to all NodeJS versions we support. At the time of Node 18.0, there was no support for the Besides, do we really want to include undici (which is a fairly large package) just to be able to have the proxy env variables? |
even having tried your solution @wolfy1339, i am still receiving connection timeouts. this has been hindering me for a few days now |
What version are you running? |
node is 18.20.2, smee is 2.0.2 |
There is also another place you need to specify the proxy:
|
…299) Fixes #194 --------- Co-authored-by: Aras Abbasi <[email protected]>
🎉 This issue has been resolved in version 3.0.0-beta.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR adds proxy support for the `EventSource` which was missing. Fixes #194
🎉 This issue has been resolved in version 2.0.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-beta.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem description
We would like to use the smee client behind a proxy. Currently, there is no possibility to add a proxy URL to the smee client, so that all outgoing connections would be proxied through a specific server.
Solution
Option one needs code changes and seems a bit more cumbersome.
Option two is fairly simple and only needs global agent dependencies and one line in index.js to import the package.
After that you can do:
GLOBAL_AGENT_HTTP_PROXY=http://<proxy-host>:<proxy-port> node ./bin/smee.js -u https://<smee-server>/<token>
Please check PR: #195
The text was updated successfully, but these errors were encountered: