Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

[Bug]: 0.11.4 continues to exist websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK) #568

Open
1 task done
kang121209 opened this issue Jun 21, 2023 · 9 comments

Comments

@kang121209
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 69, in app
await response(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 597, in aexit
raise exceptions[0]
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 273, in wrap
await func()
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 262, in stream_response
async for chunk in self.body_iterator:
File "/data/web/xiezuo.gptlala.com/aiboxs/api/common.py", line 85, in generate
async for c in massage:
File "/usr/local/lib/python3.10/site-packages/EdgeGPT/EdgeGPT.py", line 168, in ask_stream
async for response in self.chat_hub.ask_stream(
File "/usr/local/lib/python3.10/site-packages/EdgeGPT/chathub.py", line 128, in ask_stream
msg = await wss.recv()
File "/usr/local/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 568, in recv
await self.ensure_open()
File "/usr/local/lib/python3.10/site-packages/websockets/legacy/protocol.py", line 944, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

Steps to reproduce the problem

  1. Go to ....
  2. Press ....
  3. ...

What should have happened?

websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

Version where the problem happens

python3.10

What Python version are you running this with?

python3.10

What is your operating system ?

No response

Command Line Arguments

websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

Console logs

websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

Additional information

websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

[root@gptlala xiezuo.gptlala.com]# pip list|grep Ed
EdgeGPT 0.11.4

@kang121209
Copy link
Author

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 69, in app
await response(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 597, in aexit
raise exceptions[0]
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 273, in wrap
await func()
File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 262, in stream_response
async for chunk in self.body_iterator:
File "/data/web/xiezuo.gptlala.com/aiboxs/api/common.py", line 85, in generate
async for c in massage:
File "/usr/local/lib/python3.10/site-packages/EdgeGPT/EdgeGPT.py", line 168, in ask_stream
async for response in self.chat_hub.ask_stream(
File "/usr/local/lib/python3.10/site-packages/EdgeGPT/chathub.py", line 198, in ask_stream
raise Exception(
Exception: InternalError: Unhandled Dependency Failure: DeepLeo

@acheong08
Copy link
Owner

Can't replicate. Please send minimum reproducible code

@acheong08
Copy link
Owner

Exception: InternalError: Unhandled Dependency Failure: DeepLeo

Seems like a server side issue with Bing

@kang121209
Copy link
Author

    bot = await Chatbot.create(cookies=cookies, proxy=proxy)
    massage = bot.ask_stream(prompt=info.messages, conversation_style=info.conversation_style, raw=True, )
    async def generate():
        m_n=n=""					  
        async for c in massage:
            res = {}
            if c[1]["type"] == 1:
                if "messages" in c[1]["arguments"][0]:
                    if "text" in c[1]["arguments"][0]["messages"][0]:
                        newmsg = c[1]["arguments"][0]["messages"][0]["text"]
                        n=newmsg.replace(m_n,'')
                        m_n=newmsg
                        res = {"content": n, 
                        "finish_reason": c[0]}
                    else:
                        res = {"content": c[1]["arguments"][0]["messages"], 
                        "finish_reason": c[0]}
            elif c[1]["type"] == 2:
                res = c
            yield (json.dumps(res))
            if c[0] == True:
                return
    await bot.close()

exception websockets.exceptions.ConnectionClosedOK(rcvd, sent, rcvd_then_sent=None)[source]
Like ConnectionClosed, when the connection terminated properly.

A close code with code 1000 (OK) or 1001 (going away) or without a code was received and sent.

@kang121209
Copy link
Author

but i don't konw why bing closed connection?
Judging from the results, the entire conversation is not completely output, and the connection is disconnected。

@kang121209
Copy link
Author

except can raise out?

@renqabs
Copy link
Contributor

renqabs commented Jul 1, 2023

Updating to 0.11.8 version

@iamyx123
Copy link

iamyx123 commented Jul 4, 2023

I have the same issue after updating to 0.11.8

  File "C:\12333\Windows-quickstart-go-cqhttp-refs.tags.v2.5.2\python3.11\Lib\site-packages\EdgeGPT\EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
              │           │    │        └ <function ChatHub.ask_stream at 0x000002BB6DE13880>
              │           │    └ <EdgeGPT.chathub.ChatHub object at 0x000002BB6E352B50>
              │           └ <EdgeGPT.EdgeGPT.Chatbot object at 0x000002BB6E361910>
              └ (False, 'Searching the web for: `今天中国深市和沪市的股票`\n```json\n{"web_search_results":[{"index":"1","title":"市场数据 - 深交所主页","snippets...
  File "C:\12333\Windows-quickstart-go-cqhttp-refs.tags.v2.5.2\python3.11\Lib\site-packages\EdgeGPT\chathub.py", line 140, in ask_stream
    await wss.send(append_identifier({"type": 6}))
          │   │    └ <function append_identifier at 0x000002BB6DE13740>
          │   └ <function WebSocketCommonProtocol.send at 0x000002BB6DCA87C0>
          └ <websockets.legacy.client.WebSocketClientProtocol object at 0x000002BB6E397F10>
  File "C:\12333\Windows-quickstart-go-cqhttp-refs.tags.v2.5.2\python3.11\Lib\site-packages\websockets\legacy\protocol.py", line 635, in send
    await self.ensure_open()
          │    └ <function WebSocketCommonProtocol.ensure_open at 0x000002BB6DCA8B80>
          └ <websockets.legacy.client.WebSocketClientProtocol object at 0x000002BB6E397F10>
  File "C:\12333\Windows-quickstart-go-cqhttp-refs.tags.v2.5.2\python3.11\Lib\site-packages\websockets\legacy\protocol.py", line 944, in ensure_open
    raise self.connection_closed_exc()
          │    └ <function WebSocketCommonProtocol.connection_closed_exc at 0x000002BB6DCA8AE0>
          └ <websockets.legacy.client.WebSocketClientProtocol object at 0x000002BB6E397F10>

websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

@renqabs
Copy link
Contributor

renqabs commented Jul 4, 2023

I ran into this issue before upgrading to version 0.11.8, is the network latency too high?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants