-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[Bug]: api.openai.com
is blocked in China
#987
Comments
OpenAI is now blocked in China. Use VPN or proxy. |
python3 -m revChatGPT.V3 --api_key <api-key>
failed to work.api.openai.com
is blocked in China
I cannot fix this |
The following method works: $ proxychains-ng-socks5-country-control python3 -m revChatGPT.V3 --api_key sk-xxx But there is no $ python3 -m revChatGPT.V3 --api_key sk-xxx --proxy socks5h://127.0.0.1:18890 Why not add the |
Fuck!!!! |
|
Just use environment variable |
Yes. I tried and found that only the following forms worked:
All other forms failed to work. Basically, there are two categories of environment variable setting methods on terminal:
However, if python libraries are used, the options can be very rich, such as using the related packages below: https://github.com/romis2012/python-socks |
I hope it's a temporary block. |
The block will exist forever. It is better to seek a reasonable and efficient solution than to have such hope. |
I turned to use VPN and managed to overcome it. |
VPN or proxy is equivalent in solving this problem, but which is more appropriate may vary from person to person. |
On Windows 10 PowerShell:
Both of 1) and 2) works,but 3) fails,I can't fix out,it's tricky. |
For 3, your proxy must be a socks5 proxy in itself. As I've commented here, all of my following uses succeeded:
|
Of course it's socks5 proxy, actually it's on another port, doesn't work: |
In my case, it works fine, as shown below: werner@X10DAi:~$ curl -Ivx socks5h://127.0.0.1:18888 www.baidu.com
* Trying 127.0.0.1:18888...
* SOCKS5 connect to www.baidu.com:80 (remotely resolved)
* SOCKS5 request granted.
* Connected to (nil) (127.0.0.1) port 18888 (#0)
> HEAD / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
Connection: keep-alive
< Content-Length: 277
Content-Length: 277
< Content-Type: text/html
Content-Type: text/html
< Date: Sat, 04 Mar 2023 13:18:08 GMT
Date: Sat, 04 Mar 2023 13:18:08 GMT
< Etag: "575e1f6f-115"
Etag: "575e1f6f-115"
< Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
< Pragma: no-cache
Pragma: no-cache
< Server: bfe/1.0.8.18
Server: bfe/1.0.8.18
<
* Connection #0 to host (nil) left intact
# Use your own api key below:
(datasci) werner@X10DAi:~$ cmd="python3 -m revChatGPT.V3 --api_key sk-xxx"
(datasci) werner@X10DAi:~$ all_proxy=socks5://127.0.0.1:18888 $cmd
ChatGPT - Official ChatGPT API
Repo: github.com/acheong08/ChatGPT
Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.
User:
Hello.
ChatGPT:
Hello there! How can I assist you today?
User:
Exiting...
(datasci) werner@X10DAi:~$ all_proxy=socks5h://127.0.0.1:18888 $cmd
ChatGPT - Official ChatGPT API
Repo: github.com/acheong08/ChatGPT
Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.
User:
Hello.
ChatGPT:
Hi there! How can I assist you today?
User: |
VPN or ordinary proxy, there is no difference here. |
我用了 VPN 但是还是连接超时,请问这是怎么回事。。。 |
So, the culprit is your VPN server. The reasons may be various. It is difficult to draw a conclusion intuitively from the phenomenon unless it is carefully analyzed or even checked from the data package level with a packet analyzer such as tcpdump. |
i use session_token login and proxy,but somehting error occurred,is session_token wrong? error from callback <function on_open at 0x0000023CEB502160>: 'accessToken' |
Thank you, this method is useful to me, I am in China, the Japanese node, the web page can be visited, but the reverse api can't, change the node to solve the problem perfectly, and you can play happily |
Can you tell me which VPN you use and which node. it's not work with my VPN. |
Self hosted via Wireguard protocol |
OpenAI支持的国家: |
No, this is not exactly the case. The countries restriction only happens in the login authentication step. Once you've successfully authenticated, the access token based authentication will take effect, which will be valid for some time. During this period of time, there were no national restrictions as strict as those listed above. |
Is it accessible now? |
Yes. But the |
Edited by maintainer: Let's not bring politics into code. |
If you use vpn to open chatgpt, you need to give your firewall tool full control rights, and then use different nodes to test, some nodes can be opened, and it is not difficult to use these nodes. |
I can use this repo to conduct Q&A with chatGPT without using a proxy, not sure if it is because I chose the paid plan of ChatGPT |
What's your source IP location when using it? |
This is the only web request that is sent when I ask |
I don't mean the loopback address, instead, I mean the physical location which you are accessing the Internet from. Also, you can use packet analysis tool such as |
I have tried to use ask when close Fiddler and without using proxy
ask when open Fiddler and without using proxy
**Edit : This( |
For V1, when using a local proxy, which is werner@X10DAi:~$ sudo tcpdump -i lo port 18890
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:30:59.114186 IP localhost.42086 > localhost.18890: Flags [S], seq 568750027, win 65495, options [mss 65495,sackOK,TS val 1051227000 ecr 0,nop,wscale 7], length 0
07:30:59.114207 IP localhost.18890 > localhost.42086: Flags [S.], seq 3118057969, ack 568750028, win 65483, options [mss 65495,sackOK,TS val 1051227000 ecr 1051227000,nop,wscale 7], length 0
07:30:59.114224 IP localhost.42086 > localhost.18890: Flags [.], ack 1, win 512, options [nop,nop,TS val 1051227000 ecr 1051227000], length 0
07:30:59.114523 IP localhost.42086 > localhost.18890: Flags [P.], seq 1:4, ack 1, win 512, options [nop,nop,TS val 1051227000 ecr 1051227000], length 3
07:30:59.114538 IP localhost.18890 > localhost.42086: Flags [.], ack 4, win 512, options [nop,nop,TS val 1051227000 ecr 1051227000], length 0
07:30:59.115003 IP localhost.18890 > localhost.42086: Flags [P.], seq 1:3, ack 4, win 512, options [nop,nop,TS val 1051227001 ecr 1051227000], length 2
07:30:59.115012 IP localhost.42086 > localhost.18890: Flags [.], ack 3, win 512, options [nop,nop,TS val 1051227001 ecr 1051227001], length 0
07:30:59.115164 IP localhost.42086 > localhost.18890: Flags [P.], seq 4:33, ack 3, win 512, options [nop,nop,TS val 1051227001 ecr 1051227001], length 29
07:30:59.115282 IP localhost.18890 > localhost.42086: Flags [P.], seq 3:13, ack 33, win 512, options [nop,nop,TS val 1051227001 ecr 1051227001], length 10
07:30:59.157002 IP localhost.42086 > localhost.18890: Flags [P.], seq 33:550, ack 13, win 512, options [nop,nop,TS val 1051227043 ecr 1051227001], length 517
07:30:59.198815 IP localhost.18890 > localhost.42086: Flags [.], ack 550, win 512, options [nop,nop,TS val 1051227085 ecr 1051227043], length 0
07:30:59.392753 IP localhost.18890 > localhost.42086: Flags [P.], seq 13:2813, ack 550, win 512, options [nop,nop,TS val 1051227279 ecr 1051227043], length 2800
07:30:59.392869 IP localhost.18890 > localhost.42086: Flags [P.], seq 2813:4213, ack 550, win 512, options [nop,nop,TS val 1051227279 ecr 1051227043], length 1400
07:30:59.392894 IP localhost.42086 > localhost.18890: Flags [.], ack 4213, win 486, options [nop,nop,TS val 1051227279 ecr 1051227279], length 0
07:30:59.393034 IP localhost.18890 > localhost.42086: Flags [P.], seq 4213:4742, ack 550, win 512, options [nop,nop,TS val 1051227279 ecr 1051227279], length 529
07:30:59.394838 IP localhost.42086 > localhost.18890: Flags [P.], seq 550:630, ack 4742, win 512, options [nop,nop,TS val 1051227281 ecr 1051227279], length 80
07:30:59.394852 IP localhost.18890 > localhost.42086: Flags [.], ack 630, win 512, options [nop,nop,TS val 1051227281 ecr 1051227281], length 0
07:30:59.395547 IP localhost.42086 > localhost.18890: Flags [P.], seq 630:2147, ack 4742, win 512, options [nop,nop,TS val 1051227281 ecr 1051227281], length 1517
07:30:59.395556 IP localhost.18890 > localhost.42086: Flags [.], ack 2147, win 502, options [nop,nop,TS val 1051227281 ecr 1051227281], length 0
07:30:59.395592 IP localhost.42086 > localhost.18890: Flags [P.], seq 2147:2477, ack 4742, win 512, options [nop,nop,TS val 1051227281 ecr 1051227281], length 330
07:30:59.395598 IP localhost.18890 > localhost.42086: Flags [.], ack 2477, win 506, options [nop,nop,TS val 1051227281 ecr 1051227281], length 0
07:31:00.755293 IP localhost.18890 > localhost.42086: Flags [P.], seq 4742:7542, ack 2477, win 512, options [nop,nop,TS val 1051228641 ecr 1051227281], length 2800
07:31:00.755403 IP localhost.18890 > localhost.42086: Flags [P.], seq 7542:9929, ack 2477, win 512, options [nop,nop,TS val 1051228641 ecr 1051227281], length 2387
07:31:00.755512 IP localhost.42086 > localhost.18890: Flags [.], ack 9929, win 482, options [nop,nop,TS val 1051228641 ecr 1051228641], length 0
07:31:00.880346 IP localhost.18890 > localhost.42086: Flags [P.], seq 9929:12010, ack 2477, win 512, options [nop,nop,TS val 1051228766 ecr 1051228641], length 2081
07:31:00.880390 IP localhost.18890 > localhost.42086: Flags [F.], seq 12010, ack 2477, win 512, options [nop,nop,TS val 1051228766 ecr 1051228641], length 0
07:31:00.880913 IP localhost.42086 > localhost.18890: Flags [R.], seq 2477, ack 12011, win 512, options [nop,nop,TS val 1051228767 ecr 1051228766], length 0 On the other hand, I also confirmed your above observation. In short, when the reverse-proxy based method is used, which is how V1 of this project works, the local proxy is not needed. For V3 of this project, if you don't use a local proxy, the following error will be triggered: (datasci) werner@X10DAi:~$ python3 -m revChatGPT.V3 --api_key sk-xxx
ChatGPT - Official ChatGPT API
Repo: github.com/acheong08/ChatGPT
Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.
User:
Hello.
ChatGPT:
Traceback (most recent call last):
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 1075, in _create
self.do_handshake()
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 1075, in _create
self.do_handshake()
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 688, in <module>
main()
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 681, in main
for query in chatbot.ask_stream(prompt):
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 171, in ask_stream
response = self.session.post(
^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/requests/sessions.py", line 635, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/requests/adapters.py", line 547, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 691, in <module>
raise error from e
revChatGPT.typings.CLIError: Command line program unknown error
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT |
Yes, you are right. V3 does have to use a proxy, I haven't used v3 before so didn't notice this |
What's the quickest solution |
|
How this proxy works give me more explanation |
Is there an existing issue for this?
What happened?
Steps to reproduce the problem
What should have happened?
It should work normally.
Version where the problem happens
What Python version are you running this with?
No response
What is your operating system ?
No response
Command Line Arguments
Console logs
Additional information
No response
The text was updated successfully, but these errors were encountered: