Exafunction / codeium.vim

Free, ultrafast Copilot alternative for Vim and Neovim
https://codeium.com
MIT License
4.12k stars 147 forks source link

Codeium stopped working behind a proxy #195

Closed Lattay closed 1 year ago

Lattay commented 1 year ago

Codeium worked well at my workplace until recently. Now it seems to periodically send requests (as seen in btop) but nothing happen in the editor. There was an update of the proxy itself recently, but Codeium is the only software that stopped working. Is there any way to get some logging to find the problem and eventually adapt the configuration it is the problem?

pqn commented 1 year ago

Codeium tries to auto-detect the proxy configuration. You may try manually setting HTTPS_PROXY/HTTP_PROXY environmental variables to override that and see if the behavior improves. What was the change in the proxy?

Lattay commented 1 year ago

I had http variables set already, so it stoped working despite that. I am not at work this week, so I won't be able to make more tests.

Lattay commented 1 year ago

Hi, I can now confirm that with all of HTTP_PROXY, HTTPS_PROXY, http_proxy and https_proxy set, Codeium still hang. Initially, I only had the lowercase variants set and it worked well. I also confirm that the config outside Codeium is working, as everything else (including curl) works as expected.

Does Codeium use a port that is not 80/443? That could be the reason, every port is blocked in my proxy except these two.

pqn commented 1 year ago

We should only be using those ports. Is it possible to access the codeium domain without the proxy?

Lattay commented 1 year ago

Yes, it doesn't seem to be a problem:

$ curl https://api.codeium.com
{"message":"Hello World"}
pqn commented 1 year ago

Sounds like we should just avoid using the proxy. If you add the flag --detect_proxy=false to the args, does that work for you?

https://github.com/Exafunction/codeium.vim/blob/512acc2a0057f3f351674a7c2851651bf607fe8e/autoload/codeium/server.vim#L200-L207

If so, we can add a setting for that (the setting already exists in VS Code, so there's precedent).

Lattay commented 1 year ago

Oh sorry, I misread your previous comment! No in my case I can't go around the proxy. If I disable it by reseting the https_proxy variable curl hangs.

Lattay commented 1 year ago

Ok, I finally found the problem.

So checking the codeium#log#Logfile() file I realized there was something fishy. For some reason curl going through the proxy even when requesting localhost. I don't know if it's standard behavior or if it is the consequence of a bad configuration on my side, I am investing that now.

So for me the solution was to add '--noproxy', '*', to the list args in the function codeium#server#Request.

Edit: I tried on a different machine (that was not setup by myself) to eliminate the possibility that I may have done something wrong, and indeed it seems that curl goes through the proxy even for localhost. Weird...

Edit 2: Ok, so apparently its not weird, its just like this and proxies can actually handle localhost properly, but the new configuration of the proxy I deal with block it. The better solution is to not change codeium.vim source code and instead to set export NO_PROXY="localhost,127.0.0.1" in my environment.