eca icon indicating copy to clipboard operation
eca copied to clipboard

Support for proxy settings

Open Trisk3lion opened this issue 1 year ago • 11 comments

Hi!

I couldn't find a way to make the API calls go through a proxy, did I miss it maybe or is something that could be added?

I have github-copilot from work but the calls need to go through our proxy and it doesn't look like ECA (or rather hato-client) respects HTTP_PROXY/HTTPS_PROXY (or similar) without some work.

Is something that could be added?

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

Trisk3lion avatar Aug 22 '25 19:08 Trisk3lion

@Trisk3lion I believe you could set GITHUB_COPILOT_API_URL or via config providers "github-copilot" url to point to your proxy, did you try that? if so could you share your config

ericdallo avatar Aug 22 '25 19:08 ericdallo

Thanks for the quick response @ericdallo! No I didn't try that, I actually just tried /login github-copilot from the chat.

I'm no expert on these things, but I do think the GITHUB_COPILOT_API_URL should be the same as the default. What I need is that the traffic goes through the proxy server, otherwise it gets blocked.

Usually I just set the HTTPS_PROXY env variable if the application respects that, or for example with curl they have a specific --proxy cli argument that needs to be passed.

From what I could tell you are using hato-client for the HTTP requests and reading their README; it looks like that either a java.net.ProxySelector needs to be passed to the :proxy key, or that -Dhttp.proxyHost=somehost and -Dhttp.proxyPort=80 are passed to the Java process (which I guess is not possible when it is compiled with GraalVM?)

Or are there some other to do it?

Trisk3lion avatar Aug 23 '25 18:08 Trisk3lion

Interesting, I never needed to handle anything like that, but makes sense. Yep, what you suggested makes sense, I believe we can fix that we a config in eca, what you think?

Something like:

{
   "proxy": {"host": "..."
                 "port": 80}
}

Then we pass to hato on every request ?

ericdallo avatar Aug 23 '25 18:08 ericdallo

If there was a way to set that via env var maybe it would already work out of the box

ericdallo avatar Aug 23 '25 18:08 ericdallo

Yes, either or both would work great! I guess it could work similar to how the API keys work, they take both the config and environment variables into consideration?

Trisk3lion avatar Aug 23 '25 18:08 Trisk3lion

makes sense, I can work on that, let's start with only HTTPS_PROXY support for now, what value you use usually?

ericdallo avatar Aug 23 '25 18:08 ericdallo

The proxy will of course always be company specific, but many use a generic address like: "http://proxy.company.com:8080". I'm using "http://0.0.0.0:80" for HTTPS_PROXY at the moment because I run Emacs and the rest from WSL2 and therefore I need and extra proxy "jump".

Trisk3lion avatar Aug 23 '25 18:08 Trisk3lion

sounds good, I will work on that!

ericdallo avatar Aug 23 '25 19:08 ericdallo

@Trisk3lion I don't have a proxy to test, so let me know if now it works for you eca 0.33.0. Now it supports HTTP_PROXY and HTTPS_PROXY.

ericdallo avatar Aug 23 '25 19:08 ericdallo

Hi again @ericdallo!

I downloaded the latest version of eca (0.34) but I'm getting this error now when trying to run "eca server":

Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at eca.proxy$load_BANG_.invokeStatic(proxy.clj:16)
        at eca.proxy$load_BANG_.invoke(proxy.clj:9)
        at eca.main$handle_action_BANG_.invokeStatic(main.clj:93)
        at eca.main$handle_action_BANG_.invoke(main.clj:91)
        at eca.main$run_BANG_.invokeStatic(main.clj:106)
        at eca.main$run_BANG_.doInvoke(main.clj:99)
        at clojure.lang.RestFn.applyTo(RestFn.java:140)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$apply.invoke(core.clj:662)
        at eca.main$main.invokeStatic(main.clj:109)
        at eca.main$main.doInvoke(main.clj:108)
        at clojure.lang.RestFn.applyTo(RestFn.java:140)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$apply.invoke(core.clj:662)
        at eca.main$_main.invokeStatic(main.clj:134)
        at eca.main$_main.doInvoke(main.clj:132)
        at clojure.lang.RestFn.applyTo(RestFn.java:140)
        at eca.main.main(Unknown Source)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

Tried with both having HTTPS_PROXY set and when it was unset.

Maybe this is the faulting code? Could it expext the port as a string?

 (System/setProperty "http.proxyPort" (.getPort url)))))

Trisk3lion avatar Aug 24 '25 19:08 Trisk3lion

Ah yes, my fault, still need think better how to add tests for that. Released 0.34.1 fixing that, LMK!

ericdallo avatar Aug 24 '25 19:08 ericdallo