lss233 / chatgpt-mirai-qq-bot

🚀 一键部署!真正的 AI 聊天机器人!支持ChatGPT、文心一言、讯飞星火、Bing、Bard、ChatGLM、POE,多账号,人设调教,虚拟女仆、图片渲染、语音发送 | 支持 QQ、Telegram、Discord、微信 等平台
GNU Affero General Public License v3.0
12.97k stars 1.55k forks source link

[BUG] 在宽带连接的情况下出现网路异常(ai:claude) #881

Closed ccccchisato closed 1 year ago

ccccchisato commented 1 year ago

提交 issue 前,请先确认:

表现
在校园宽带连接的情况下,不能正常使用。在热点连接的情况下可以正常使用。 ai平台状态:大多时候接收不到,有些时候收到且回应但是机器人没能发给我

运行环境:

复现步骤
描述你是如何触发这个 BUG 的

  1. 电脑定时关机,机器人(连热点的情况下)在关机前运行。在一次经过上述操作后,“启动ChatGPT.cmd”中出现错误。之后几天里在宽带连接的情况下,大概率不能使用;有时候刚开始能使用,后面不能使用;有时候一开始就不能用,后来能正常使用。小概率能全程正常使用。在使用手机热点连接的情况下,能正常使用。 试过重装2.5.1项目,并没有解决问题;

预期行为
描述认为正常情况下应该看见的情况:不会跳出大段日志,正常运行,正常响应。

以下是其中一次在“启动ChatGPT.cmd”中的日志, 2023-05-25 18:16:43.932 | ERROR | utils.retry:wrapper:25 - Traceback (most recent call last):

File "asyncio\windows_events.py", line 494, in finish_recv def connect(self, conn, address):

OSError: [WinError 64] 指定的网络名不再可用。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "asyncio\proactor_events.py", line 286, in _loop_reading self._write_fut.add_done_callback(self._loop_writing) │ │ │ └ <function _ProactorBaseWritePipeTransport._loop_writing at 0x00000295E77F59E0> │ │ └ <_ProactorSocketTransport closed> │ └ None └ <_ProactorSocketTransport closed>

File "asyncio\windows_events.py", line 846, in _poll

File "asyncio\windows_events.py", line 498, in finish_recv _overlapped.BindLocal(conn.fileno(), conn.family) │ └ └ <module '_overlapped' from 'D:\桌面\Q-chat-bot\python3.11\_overlapped.pyd'>

ConnectionResetError: [WinError 64] 指定的网络名不再可用。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_exceptions.py", line 10, in map_exceptions yield File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore\backends\asyncio.py", line 78, in start_tls raise exc File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore\backends\asyncio.py", line 69, in start_tls ssl_stream = await anyio.streams.tls.TLSStream.wrap( │ │ │ │ └ <classmethod(<function TLSStream.wrap at 0x00000295EBD1CEA0>)> │ │ │ └ <class 'anyio.streams.tls.TLSStream'> │ │ └ <module 'anyio.streams.tls' from 'D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio\streams\tls.py'> │ └ <module 'anyio.streams' from 'D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio\streams\init.py'> └ <module 'anyio' from 'D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio\init.py'> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio\streams\tls.py", line 122, in wrap await wrapper._call_sslobject_method(ssl_object.do_handshake) │ │ │ └ <function SSLObject.do_handshake at 0x00000295E5F2F740> │ │ └ <ssl.SSLObject object at 0x00000295EBECC490> │ └ <function TLSStream._call_sslobject_method at 0x00000295EBD1CF40> └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x00000295EBECC650>, standardcompatible=False, ... File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio\streams\tls.py", line 137, in _call_sslobject_method data = await self.transport_stream.receive() │ │ └ <function SocketStream.receive at 0x00000295EBD68540> │ └ <anyio._backends._asyncio.SocketStream object at 0x00000295EBECC650> └ TLSStream(transport_stream=<anyio._backends._asyncio.SocketStream object at 0x00000295EBECC650>, standardcompatible=False, ... File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\anyio_backends_asyncio.py", line 1274, in receive raise self._protocol.exception │ │ └ BrokenResourceError() │ └ <anyio._backends._asyncio.StreamProtocol object at 0x00000295EBECC610> └ <anyio._backends._asyncio.SocketStream object at 0x00000295EBECC650>

anyio.BrokenResourceError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_transports\default.py", line 60, in map_httpcore_exceptions yield File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_transports\default.py", line 353, in handle_async_request resp = await self._pool.handle_async_request(req) │ │ │ └ <Request [b'POST']> │ │ └ <function AsyncConnectionPool.handle_async_request at 0x00000295E91F6200> │ └ <httpcore.AsyncConnectionPool object at 0x00000295EBE981D0> └ <httpx.AsyncHTTPTransport object at 0x00000295EBEBF0D0> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_async\connection_pool.py", line 253, in handle_async_request raise exc File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_async\connection_pool.py", line 237, in handle_async_request response = await connection.handle_async_request(request) │ │ └ <Request [b'POST']> │ └ <function AsyncHTTPConnection.handle_async_request at 0x00000295E9052CA0> └ <AsyncHTTPConnection [CONNECTION FAILED]> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_async\connection.py", line 86, in handle_async_request raise exc File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_async\connection.py", line 63, in handle_async_request stream = await self._connect(request) │ │ └ <Request [b'POST']> │ └ <function AsyncHTTPConnection._connect at 0x00000295E91F54E0> └ <AsyncHTTPConnection [CONNECTION FAILED]> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_async\connection.py", line 150, in _connect stream = await stream.start_tls(**kwargs) │ │ └ {'ssl_context': <ssl.SSLContext object at 0x00000295EBE75520>, 'server_hostname': 'chatgpt-proxy.lss233.com', 'timeout': 60} │ └ <function AsyncIOStream.start_tls at 0x00000295EBD6BF60> └ <httpcore.backends.asyncio.AsyncIOStream object at 0x00000295EBECC110> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore\backends\asyncio.py", line 66, in start_tls with map_exceptions(exc_map): │ └ {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectErro... └ <function map_exceptions at 0x00000295E9075580>

File "contextlib.py", line 155, in exit

File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions raise to_exc(exc) └ <class 'httpcore.ConnectError'>

httpcore.ConnectError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "D:\桌面\Q-chat-bot\chatgpt\bot.py", line 54, in loop.run_until_complete(asyncio.gather(*bots)) │ │ │ │ └ [<Task pending name='Task-2' coro=<start_task() running at D:\桌面\Q-chat-bot\chatgpt\platforms\onebot_bot.py:356> wait_for=<_G... │ │ │ └ <function gather at 0x00000295E7792CA0> │ │ └ <module 'asyncio' from 'D:\桌面\Q-chat-bot\python3.11\python311.zip\asyncio\init.pyc'> │ └ <function BaseEventLoop.run_until_complete at 0x00000295E77AFB00> └

File "asyncio\base_events.py", line 640, in run_until_complete sock.setblocking(False)

File "asyncio\windows_events.py", line 321, in run_forever

File "asyncio\base_events.py", line 607, in run_forever sock.close()

File "asyncio\base_events.py", line 1922, in _run_once

File "asyncio\events.py", line 80, in _run self._loop = loop │ └ <member '_loop' of 'Handle' objects> └ <Handle <TaskStepMethWrapper object at 0x00000295EBEB9180>()>

File "D:\桌面\Q-chat-bot\chatgpt\universal.py", line 222, in request async for rendered in task: └ <async_generator object retry..decorator..wrapper at 0x00000295EB23B6E0>

File "D:\桌面\Q-chat-bot\chatgpt\utils\retry.py", line 21, in wrapper async for result in func(*args, **kwargs): │ │ └ {'prompt': '你好', 'chain': MessageChain([Plain(text='你好')]), 'name': 'Chisato'} │ └ (<conversation.ConversationContext object at 0x00000295EBC0DE10>,) └ <function ConversationContext.ask at 0x00000295EBB96C00>

File "D:\桌面\Q-chat-bot\chatgpt\conversation.py", line 187, in ask async for item in self.adapter.ask(prompt): │ │ │ └ ' 女友,你好' │ │ └ <function ClaudeInSlackAdapter.ask at 0x00000295EBA1E8E0> │ └ <adapter.claude.slack.ClaudeInSlackAdapter object at 0x00000295EBBA65D0> └ <conversation.ConversationContext object at 0x00000295EBC0DE10>

File "D:\桌面\Q-chat-bot\chatgpt\adapter\claude\slack.py", line 77, in ask async with self.client.stream( │ │ └ <function AsyncClient.stream at 0x00000295E92107C0> │ └ <httpx.AsyncClient object at 0x00000295EBE86D50> └ <adapter.claude.slack.ClaudeInSlackAdapter object at 0x00000295EBBA65D0>

File "contextlib.py", line 204, in aenter

File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_client.py", line 1576, in stream response = await self.send( │ └ <function AsyncClient.send at 0x00000295E9210860> └ <httpx.AsyncClient object at 0x00000295EBE86D50> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_client.py", line 1620, in send response = await self._send_handling_auth( │ └ <function AsyncClient._send_handling_auth at 0x00000295E9210900> └ <httpx.AsyncClient object at 0x00000295EBE86D50> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_client.py", line 1648, in _send_handling_auth response = await self._send_handling_redirects( │ └ <function AsyncClient._send_handling_redirects at 0x00000295E92109A0> └ <httpx.AsyncClient object at 0x00000295EBE86D50> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_client.py", line 1685, in _send_handling_redirects response = await self._send_single_request(request) │ │ └ <Request('POST', 'https://chatgpt-proxy.lss233.com/claude-in-slack/backend-api/conversation')> │ └ <function AsyncClient._send_single_request at 0x00000295E9210A40> └ <httpx.AsyncClient object at 0x00000295EBE86D50> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_client.py", line 1722, in _send_single_request response = await transport.handle_async_request(request) │ │ └ <Request('POST', 'https://chatgpt-proxy.lss233.com/claude-in-slack/backend-api/conversation')> │ └ <function AsyncHTTPTransport.handle_async_request at 0x00000295E9205940> └ <httpx.AsyncHTTPTransport object at 0x00000295EBEBF0D0> File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_transports\default.py", line 352, in handle_async_request with map_httpcore_exceptions(): └ <function map_httpcore_exceptions at 0x00000295E90536A0>

File "contextlib.py", line 155, in exit

File "D:\桌面\Q-chat-bot\python3.11\Lib\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions raise mapped_exc(message) from exc │ └ '' └ <class 'httpx.ConnectError'>

httpx.ConnectError 2023-05-25 18:16:43.997 | ERROR | utils.retry:wrapper:26 - 处理请求时遇到错误, 将在 3 秒后重试...

其他内容
另外,有些时候机器人响应有点慢,不知道有没有问题。在热点连接的情况下,发送“你好”,经过ai得到回复的时间大概12秒

ccccchisato commented 1 year ago

我想再观察几天,可能是我的网络问题