circlestarzero / EX-chatGPT

Let ChatGPT truly learn how to go online and call APIs! 'EX-ChatGPT' can rival and even surpass NewBing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

请求时总是返回 EOF occurred in violation of protocol (_ssl.c:992)

minquejoe opened this issue · comments

  • aarch64 GNU/Linux 系统架构
  • 挂了代理了,容器内能 curl www.google.com
  • 容器内 urllib3==1.25.11
  • 错误日志如下:
192.168.1.109 - - [18/Mar/2023 18:30:45] "GET /api/APIProcess HTTP/1.1" 200 -

Debugging middleware caught exception in streamed response at a point where response headers were already sent.

Traceback (most recent call last):

  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 670, in urlopen

    httplib_response = self._make_request(

                       ^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 381, in _make_request

    self._validate_conn(conn)

  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn

    conn.connect()

  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 362, in connect

    self.sock = ssl_wrap_socket(

                ^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 386, in ssl_wrap_socket

    return context.wrap_socket(sock, server_hostname=server_hostname)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/ssl.py", line 517, in wrap_socket

    return self.sslsocket_class._create(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/ssl.py", line 1075, in _create

    self.do_handshake()

  File "/usr/local/lib/python3.11/ssl.py", line 1346, in do_handshake

    self._sslobj.do_handshake()

ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:992)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 439, in send

    resp = conn.urlopen(

           ^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 726, in urlopen

    retries = retries.increment(

              ^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 446, in increment

    raise MaxRetryError(_pool, url, error or ResponseError(cause))

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:992)')))


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/app/chatGPTEx/search.py", line 93, in web

    resp = directQuery(f'Query: {query}', conv_id=  conv_id)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/chatGPTEx/search.py", line 153, in directQuery

    response = chatbot.ask(prompt+'\n'+query,convo_id=conv_id)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/app/chatGPTEx/optimizeOpenAI.py", line 206, in ask

    full_response: str = "".join(response)

                         ^^^^^^^^^^^^^^^^^

  File "/app/chatGPTEx/optimizeOpenAI.py", line 160, in ask_stream

    response = self.session.post(

               ^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 590, in post

    return self.request('POST', url, data=data, json=json, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 542, in request

    resp = self.send(prep, **send_kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 655, in send

    r = adapter.send(request, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 514, in send

    raise SSLError(e, request=request)

requests.exceptions.SSLError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:992)')))

192.168.1.109 - - [18/Mar/2023 18:30:45] "GET /api/query?mode=web&uuid=default&prompt=&msg=hi HTTP/1.1" 200 -

会是什么问题呢?

补充:

  • 代理用的是V2ray,协议为trojan,地区为新加坡
  • 使用docker部署
    dockerfile如下:
# FROM python:slim or python:alpine 以精简镜像,但需要额外下载依赖
FROM python:3.11.2

# for tiktoken
COPY tiktoken-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl /temp/tiktoken-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
RUN pip install /temp/tiktoken-0.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

# 使用清华源以提高下载速度
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
 

ENV LANG="C.UTF-8" \
    TZ="Asia/Shanghai" \
    REPO_URL="https://ghproxy.com/https://github.com/circlestarzero/EX-chatGPT.git" \
    WORKDIR="/app" \
    AUTO_UPDATE="true"

WORKDIR ${WORKDIR}

RUN git clone -b main ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
    && chmod +x ${WORKDIR}/chatGPTEx/entrypoint.sh \
    && sed -i 's/app.run(host="127\.0\.0\.1",port=1234)/#app.run(host="127\.0\.0\.1",port=1234)/g; s/# app.run(host="0\.0\.0\.0", port = 5000)/app.run(host="0\.0\.0\.0", port = 5000)/g' ${WORKDIR}/chatGPTEx/main.py \
    && sed -i "s#program_dir+'/apikey.ini'#'/config/apikey.ini'#g" /app/chatGPTEx/main.py \
    && sed -i "s#program_dir+'/apikey.ini'#'/config/apikey.ini'#g" /app/chatGPTEx/search.py \
    && sed -i "s#os\.path\.join(program_dir, 'apikey.ini')#'/config/apikey.ini'#g" /app/chatGPTEx/search.py \
    && mkdir /config

EXPOSE 5000

VOLUME ["/config"]

ENTRYPOINT ["/app/chatGPTEx/entrypoint.sh"]

docker-compose.yml如下:

version: '3'
services:

  exchatgpt:
    build:
      context: .
      dockerfile: Dockerfile
    image: exchatgpt
    volumes:
      - /home/orangepi/EXchatGPT/config:/config   # 冒号左边请修改为你想保存配置的路径
    container_name: exchatgpt
    restart: unless-stopped
    logging:
      driver: "json-file"
      options:
        max-size: "1024m"
        max-file: "3"
    ports:
      - "5000:5000"
    # TODO: 添加环境变量以直接启动
    environment:
      - "GOOGLE_API_KEY0=XXX"
      - "SEARCH_ENGINE_ID0=XXX"
      - "key0=XXX"
      - "WOLFRAMALPHA_APP_ID0=XXX"
      - "API_PROXY=https://api.openai.com/v1/chat/completions"
      - "AZURE_SUBSCRIPTIONKEY="
      - "AZURE_REGION="
      - "AUTO_UPDATE=true"

代理问题,不一定非大陆和香港地区的代理就必然可行。