-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
'Connection Error' when setup OpenAI on Model Provider after upgrading to 0.14.1 #11839
Comments
Hey @Ynewtime! 👋 I'm here to help you with your Dify issue. I can assist with bug solving, answering questions, and guide you on becoming a contributor. Let's dive into resolving the issue together! The 'Connection Error' you're experiencing when setting up OpenAI on the Model Provider after upgrading to version 0.14.1 is likely due to changes in how Docker Compose handles proxy settings in this version. In Dify 0.14.0 and likely 0.14.1, Docker Compose reads the system proxy environment variables (HTTP_PROXY and HTTPS_PROXY), which can interfere with API connections if these variables are set to values like 127.0.0.1:7890. To resolve this issue, you can try the following:
These steps should help establish the connection successfully, similar to how it worked in version 0.13.2 [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
I've tried both these suggestions but none of them work in 0.14.1, same issue. |
I don't think it's related. Because these 2 settings have exist for a while. |
Not sure if it's related but as per the .env.example file comparison between 0.13.2 and 0.14.1, the HTTP(S)_PROXY config exist in 0.14.1 only? |
Hi there, thanks. I'ved tried (yesterday and today with the latest commit) commented out those 2 lines but same issue there. Kindly find the dify-api container full logs here:
My WSL2 configuration (.wslconfig): # https://learn.microsoft.com/en-us/windows/wsl/wsl-config#main-wsl-settings
[wsl2]
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config#experimental-settings
[experimental]
autoMemoryReclaim=dropcache
sparseVhd=true
bestEffortDnsParsing=true
hostAddressLoopback=true ...notice that I've enabled the networkingMode=mirrored mode, which ensures the best network experience when developing in WSL2. With clash proxy enabled on Windows, you can use the clash proxy with no extra steps right in WSL2: ➜ docker git:(main) echo $http_proxy
http://127.0.0.1:7890 But still, as I've mentioned, all the environment and configurations are the same for 0.13.2 and 0.14.1, but connection fails for 0.14.1 when configuring new Model Providers. |
The log shows that your dify is still using the proxy setting. Make sure you unset the HTTP_PROXY and HTTPS_PROXY, all upper case.
|
do we need to consider remove the http_proxy and https_proxy in env args...it will break some users |
@crazywoola This commit is added just 4 days ago, and is about the same time as Dify v0.14.0 rolled out when people start to upgrade and report issue. By my understanding, this commit is trying to use proxy to pull docker image which I am sure there are other methods achieving the same. But not to digress from the discussion, the environment variables is passed to the dify api container as well. In the case of a proxy like 127.0.0.1:7890, dify will access its internal network address rather than the host machine, which caused problems. |
"Make sure you unset the HTTP_PROXY and HTTPS_PROXY, all upper case" ---- this make no sense:
Stop clash as system proxy and use clash's TUN mode instead ---- this is not required because as I mentioned in the last comment:
...which means as long as I enabled Clash as system proxy, WSL2 will have proxy support transparently, no need to manully config anything else in WSL2. And only with the proxy on, I will be able to connect to OpenAI and Claude endpoint from my WSL2 environment: ➜ docker git:(main) wget -q --spider https://claude.ai && echo "connected" || echo "not connected"
connected |
I hope your problem gets resolved soon. |
@AugNSo You are right, needs to be reverted. |
nice explain! |
It's true that living in mainland China comes with a lot of internet knowledge......... |
@gaoyuexit the latest code has already fixed the issue. |
I am using the latest code, maybe it's my own problem? |
It works now. With the #11906 fix, now 0.14.1 can connect to OpenAI endpoint, same as 0.13.2 (in China Mainland, enable WSL2 mirrored networkingMode and Clash proxy). Kudos to the team! |
Self Checks
Dify version
0.14.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Same network configuration (Chinese Mainland with Clash Proxy), same environment (WSL2 + Docker Desktop), one was launched from 0.13.2 and the other launched from 0.14.1:
Notice that the app launched from 0.13.2 can setup OpenAI (and chat) successfully, but the app launched from 0.14.1 cannot even setup OpenAI with error: 'Connection Error' as shared screenshots.
Environment: WSL2 2.3.26.0 + Docker Desktop v4.37.1
Network: China Mainland with Clash Proxy
Reproduction:
...both apps can start up normally as per the reproduction steps above with no other configurations differed. Only the error happens in OpenAI setup of 0.14.1.
✔️ Expected Behavior
0.14.1 seems to have proxy configuration enhanced, as per this #11681, though it did introduces connection error.
Expect the app to behave as the same as 0.13.2 version.
❌ Actual Behavior
0.14.1: OpenAI and Claude API cannot be setup succesfully, connection error.
The text was updated successfully, but these errors were encountered: