Closed JackChow6 closed 1 year ago
以上是我所有的设置,但是仍显示错误,不知道问题出在哪
我觉得应该需要修改两个地方:
http://<IP>:1000
改为 http://0.0.0.0:1000
HTTP_PROXY
和 HTTPS_PROXY
的值修改为 http://host.docker.internal:1000
另外,我有个疑问,为什么这个 docker desktop (好像是吧)显示的代理:
与 docker-compose.yml 里配置设置的不一样:
按照您的意见修改完后仍然报错
我尝试ping ping host.docker.internal PING host.docker.internal (240.0.0.71): 56 data bytes 64 bytes from 240.0.0.71: icmp_seq=0 ttl=64 time=0.152 ms 64 bytes from 240.0.0.71: icmp_seq=1 ttl=64 time=0.300 ms 64 bytes from 240.0.0.71: icmp_seq=2 ttl=64 time=0.381 ms 64 bytes from 240.0.0.71: icmp_seq=3 ttl=64 time=0.368 ms 64 bytes from 240.0.0.71: icmp_seq=4 ttl=64 time=0.325 ms 64 bytes from 240.0.0.71: icmp_seq=5 ttl=64 time=0.213 ms 64 bytes from 240.0.0.71: icmp_seq=6 ttl=64 time=0.240 ms 64 bytes from 240.0.0.71: icmp_seq=7 ttl=64 time=0.185 ms 64 bytes from 240.0.0.71: icmp_seq=8 ttl=64 time=0.268 ms 64 bytes from 240.0.0.71: icmp_seq=9 ttl=64 time=0.354 ms 64 bytes from 240.0.0.71: icmp_seq=10 ttl=64 time=0.387 ms 64 bytes from 240.0.0.71: icmp_seq=11 ttl=64 time=0.308 ms
ping 172.17.0.1:1000 PING 172.17.0.1:1000 (240.0.1.206): 56 data bytes 64 bytes from 240.0.1.206: icmp_seq=0 ttl=64 time=0.188 ms 64 bytes from 240.0.1.206: icmp_seq=1 ttl=64 time=0.278 ms 64 bytes from 240.0.1.206: icmp_seq=2 ttl=64 time=0.227 ms 64 bytes from 240.0.1.206: icmp_seq=3 ttl=64 time=0.319 ms 64 bytes from 240.0.1.206: icmp_seq=4 ttl=64 time=0.384 ms 64 bytes from 240.0.1.206: icmp_seq=5 ttl=64 time=0.276 ms ^C --- 172.17.0.1:1000 ping statistics --- 6 packets transmitted, 6 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.188/0.279/0.384/0.063 ms
nc localhost 1000 -v
# 显示 "Connection to ... succeeded!" 则成功
或
telnet localhost 1000
# 显示 "Connected to ..." 则成功
nc host.docker.internal 1000 -v
或
telnet host.docker.internal 1000
看看能否成功连接。
(万一 nc 和 telnet 都没有的话随便装一个吧)
telnet localhost 1000 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused telnet: Unable to connect to remote host
显示失败了
那说明你的代理软件没有配置好吧
在哪里设置呢
再改回 127.0.0.1 试试?😅
我吧端口重置 为原来的,就"Connection to ... succeeded!"
那你把 docker-compose.yml
里面的配置改成对应的呗
environment:
# host.docker.internal 是 docker desktop 默认带有的访问宿主机的域名,
# 但不一定有效,例如我的 docker vm 访问宿主机的 ip 需要用 192.168.5.2
- HTTP_PROXY=http://host.docker.internal:1082
- HTTPS_PROXY=http://host.docker.internal:1082
这样设置还是报错诶
During handling of the above exception, another exception occurred: 2023-06-06 19:35:25 2023-06-06 19:35:25 Traceback (most recent call last): 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/grpc/_server.py", line 444, in _call_behavior 2023-06-06 19:35:25 response_or_iterator = behavior(argument, context) 2023-06-06 19:35:25 File "/app/chatgpt/grpcapi.py", line 37, in NewSession 2023-06-06 19:35:25 session_id = self.multiChatGPT.new_session(config) 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 289, in new_session 2023-06-06 19:35:25 self.chatgpts[session_id] = ChatGPTProxy( 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 189, in init 2023-06-06 19:35:25 self.renew() 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 193, in renew 2023-06-06 19:35:25 self.chatgpt = self._new_chatgpt(self.config) 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 207, in _new_chatgpt 2023-06-06 19:35:25 new_chatgpt = ChatGPTv3(config={ 2023-06-06 19:35:25 File "/app/chatgpt/chatbot.py", line 94, in init 2023-06-06 19:35:25 self.chatbot = ChatbotV3( 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 68, in init 2023-06-06 19:35:25 if self.get_token_count("default") > self.max_tokens: 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 116, in get_token_count 2023-06-06 19:35:25 encoding = tiktoken.encoding_for_model(self.engine) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 75, in encoding_for_model 2023-06-06 19:35:25 return get_encoding(encoding_name) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/registry.py", line 63, in get_encoding 2023-06-06 19:35:25 enc = Encoding(constructor()) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken_ext/openai_public.py", line 64, in cl100k_base 2023-06-06 19:35:25 mergeable_ranks = load_tiktoken_bpe( 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 114, in load_tiktoken_bpe 2023-06-06 19:35:25 contents = read_file_cached(tiktoken_bpe_file) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 46, in read_file_cached 2023-06-06 19:35:25 contents = read_file(blobpath) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 24, in read_file 2023-06-06 19:35:25 return requests.get(blobpath).content 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get 2023-06-06 19:35:25 return request("get", url, params=params, kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request 2023-06-06 19:35:25 return session.request(method=method, url=url, kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request 2023-06-06 19:35:25 resp = self.send(prep, send_kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send 2023-06-06 19:35:25 r = adapter.send(request, **kwargs) 2023-06-06 19:35:25 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 559, in send 2023-06-06 19:35:25 raise ProxyError(e, request=request) 2023-06-06 19:35:25 requests.exceptions.ProxyError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff8821b4c0>: Failed to establish a new connection: [Errno 111] Connection refused')))
然后这个还是不一样 好奇怪
你重启服务组了没?重新 docker compose up -d
一下试试
重组之后代理显示正常,但还是报错
你在容器里试试能 telnet 连到代理吗
(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % telnet host.docker.internal 1082 Trying 240.0.0.33... Connected to host.docker.internal. Escape character is '^]'. Connection closed by foreign host.
(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % nc host.docker.internal 1082 -v Connection to host.docker.internal port 1082 [tcp/amt-esd-prot] succeeded!
(base) zjk-macminim1@Zjk-MacdeMac-mini
啊?这不是容器内叭 🥺
你试试这种炼金去的:
docker compose exec chatgpt_chatbot sh
(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % docker compose exec chatgpt_chatbot sh
telnet: could not resolve host.docker.internal/1082: Name or service not known
显示错误
这个 host.docker.internal 按照 docker desktop 的文档应该是可用的。
所以还是代理设置的问题吧,我还是觉得代理要监听 0.0.0.0 应该才能访问到,你再试试改一下?(改完要重启代理软件哦)
(base) zjk-macminim1@Zjk-MacdeMac-mini muvtuber % docker compose exec chatgpt_chatbot sh
telnet: could not resolve host.docker.internal/1082: Name or service not known
还是显示错误诶
你在宿主机开一个其他服务,在容器内能访问到嘛
比如宿主机uh:
python -m http.server 8000
然后在里:
telnet host.docker.internal 8000
您使用的代理软件是什么,或许我 change 一下软件就行了?
b x不行诶
Docker desktop 文档不是说这个地址是可用的嘛 😭(我自己是用的 colima 所以我不清楚 docker desktop 的具体情况
emmm,开 python 服务之后 mac 弹的那个允许传入网络连接对话框允许了没
允许了的
太难了吧,宝子
这个网络就是很烦,每个人的情况都不一样。解决这个办法挺多的,主要不知道你用啥方案比较方便
你在容器里和 docker 的 vm 里分别 host host.docker.internal
能查到 ip 嘛
请问应该怎么查呢
我ifconfig
(base) zjk-macminim1@Zjk-MacdeMac-mini ~ % ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=400
(base) zjk-macminim1@Zjk-MacdeMac-mini ~ % host host.docker.internal host.docker.internal has address 240.0.0.26 host.docker.internal has address 240.0.0.26
我自己常用的一种手段是在容器内开一个陷阱服务,然后从宿主机去访问这个服务,便记录下了容器眼里宿主机的 ip。大概就这样吧。
除了找出 ip 去连,这个问题其他解决方案也很多:
还有,想起来以前有个老哥说他是这么解决的:
chatgpt的话我通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址)能正常使用了
i get it ,通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),但是得把dockerfile和docker compose 2个文件里的代理都删掉!!!!感谢大佬,晚安
i get it ,通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),但是得把dockerfile和docker compose 2个文件里的代理都删掉!!!!感谢大佬,晚安
我是把他注释掉了
太好了🥹 但是为啥,这个具体是怎么个配法我还是没理解(我没用docker desktop不了解)。
通过docker desktop的settings-resources-proxies写了宿主机的ip(我写的就是宿主机以太网下的本地ipv4地址),
这个是怎么配的呢?我想了解一下在文档里详细写一写。
或者如果你能帮忙 pr 改一改 README 就更棒了🥰
因为我们想让docker使用宿主机的代理,所以我们在docker desktop里settings-resources-proxies设置代理地址(宿主机以太网下的本地ipv4地址+代理软件设置的端口),同时把dockerfile和doccker compose 2个文件中的有关proxy的内容注释掉或删除,这个或许会影响docker 走宿主机的代理,最后感谢大佬的提醒[玫瑰][玫瑰][玫瑰]
哦哦,是 Settings -> Resources -> Proxies 的意思啊。这下看懂了。我之前以为是在某个神秘的地方去写某个 settings-resources-proxies
变量 😰 多谢哈,我一会儿给加到文档里去。
这样设置对小白很友好🥰
2023-06-05 22:01:07 2023-06-05 22:01:07 During handling of the above exception, another exception occurred: 2023-06-05 22:01:07 2023-06-05 22:01:07 Traceback (most recent call last): 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send 2023-06-05 22:01:07 resp = conn.urlopen( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen 2023-06-05 22:01:07 retries = retries.increment( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment 2023-06-05 22:01:07 raise MaxRetryError(_pool, url, error or ResponseError(cause)) 2023-06-05 22:01:07 urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffffa80f2230>: Failed to establish a new connection: [Errno -2] Name or service not known'))) 2023-06-05 22:01:07 2023-06-05 22:01:07 During handling of the above exception, another exception occurred: 2023-06-05 22:01:07 2023-06-05 22:01:07 Traceback (most recent call last): 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/grpc/_server.py", line 444, in _call_behavior 2023-06-05 22:01:07 response_or_iterator = behavior(argument, context) 2023-06-05 22:01:07 File "/app/chatgpt/grpcapi.py", line 37, in NewSession 2023-06-05 22:01:07 session_id = self.multiChatGPT.new_session(config) 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 289, in new_session 2023-06-05 22:01:07 self.chatgpts[session_id] = ChatGPTProxy( 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 189, in init 2023-06-05 22:01:07 self.renew() 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 193, in renew 2023-06-05 22:01:07 self.chatgpt = self._new_chatgpt(self.config) 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 207, in _new_chatgpt 2023-06-05 22:01:07 new_chatgpt = ChatGPTv3(config={ 2023-06-05 22:01:07 File "/app/chatgpt/chatbot.py", line 94, in init 2023-06-05 22:01:07 self.chatbot = ChatbotV3( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 68, in init 2023-06-05 22:01:07 if self.get_token_count("default") > self.max_tokens: 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/revChatGPT/V3.py", line 116, in get_token_count 2023-06-05 22:01:07 encoding = tiktoken.encoding_for_model(self.engine) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/model.py", line 75, in encoding_for_model 2023-06-05 22:01:07 return get_encoding(encoding_name) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/registry.py", line 63, in get_encoding 2023-06-05 22:01:07 enc = Encoding(constructor()) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken_ext/openai_public.py", line 64, in cl100k_base 2023-06-05 22:01:07 mergeable_ranks = load_tiktoken_bpe( 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 114, in load_tiktoken_bpe 2023-06-05 22:01:07 contents = read_file_cached(tiktoken_bpe_file) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 46, in read_file_cached 2023-06-05 22:01:07 contents = read_file(blobpath) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/tiktoken/load.py", line 24, in read_file 2023-06-05 22:01:07 return requests.get(blobpath).content 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get 2023-06-05 22:01:07 return request("get", url, params=params, kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request 2023-06-05 22:01:07 return session.request(method=method, url=url, kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request 2023-06-05 22:01:07 resp = self.send(prep, send_kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send 2023-06-05 22:01:07 r = adapter.send(request, **kwargs) 2023-06-05 22:01:07 File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 559, in send 2023-06-05 22:01:07 raise ProxyError(e, request=request) 2023-06-05 22:01:07 requests.exceptions.ProxyError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffffa80f2230>: Failed to establish a new connection: [Errno -2] Name or service not known')))