FastGPT icon indicating copy to clipboard operation
FastGPT copied to clipboard

多用户并发访问报错 Premature close

Open lktsuer opened this issue 1 year ago • 2 comments

例行检查

  • [ ] 我已确认目前没有类似 issue
  • [ ] 我已完整查看过项目 README,以及项目文档
  • [ ] 我使用了自己的 key,并确认我的 key 是可正常使用的
  • [ ] 我理解并愿意跟进此 issue,协助测试和提供反馈
  • [x] 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

你的版本

  • [ ] 公有云版本
  • [x] 私有部署版本, 具体版本号: v4.8.2 各版本均能复现

问题描述, 日志截图 多线程使用同一个api key,同时访问一个应用程序,导致应用程序报错。 使用同样的程序直接访问大模型接口,返回是正常的。 Fastgpt日志如下

fastgpt-test  | 188 new ObjectId("663ae44d3cca43f1faf05296")
fastgpt-test  | [INFO] 2024-05-29 08:59:13 [dispatchWorkFlow] nodeRunWithActive: AI 对话(知识库) 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 [dispatchWorkFlow] nodeRunWithSkip: AI 对话(通用) 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 152 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 81 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 119 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 0, token: 35 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 8, token: 2608 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 5, token: 141 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 196 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 69 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 152 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 208 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 116 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 155 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 0, token: 49 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 1, token: 102 
fastgpt-test  | [INFO] 2024-05-29 08:59:13 Count token time: 5, token: 2235 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 2779ms 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 1100ms 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Count token time: 7, token: 2338 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 completions running time: 3.023s 
fastgpt-test  | [INFO] 2024-05-29 08:59:14 finish completions {"source":"api","teamId":"66473178bae7715efc361fca","totalPoints":0}
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 3024ms 
fastgpt-test  | [ERROR] 2024-05-29 08:59:14 sse error: Premature close 
fastgpt-test  | {
fastgpt-test  |   message: 'Premature close',
fastgpt-test  |   stack: 'Error: Premature close\n' +
fastgpt-test  |     '    at IncomingMessage.<anonymous> (/app/projects/app/.next/server/chunks/15428.js:9:506432)\n' +
fastgpt-test  |     '    at Object.onceWrapper (node:events:628:28)\n' +
fastgpt-test  |     '    at IncomingMessage.emit (node:events:514:28)\n' +
fastgpt-test  |     '    at emitCloseNT (node:internal/streams/destroy:132:10)\n' +
fastgpt-test  |     '    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)'
fastgpt-test  | }
fastgpt-test  | [INFO] 2024-05-29 08:59:14 Request finish /api/v1/chat/completions, time: 1381ms 

大模型报错如下:

INFO:     192.168.80.5:42760 - "POST /v1/chat/completions HTTP/1.1" 200 OK
INFO:     192.168.80.5:42770 - "POST /v1/chat/completions HTTP/1.1" 200 OK
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 282, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 271, in wrap
    await func()
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/sse_starlette/sse.py", line 221, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 568, in receive
    await self.message_event.wait()
  File "/disk/bcmi/miniconda3/envs/glm3/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f55e6cdfd90

复现步骤 多用户访问即可 预期结果

相关截图

lktsuer avatar May 29 '24 09:05 lktsuer

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

lijiajun1997 avatar May 29 '24 09:05 lijiajun1997

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

lktsuer avatar May 29 '24 09:05 lktsuer

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

c121914yu avatar May 30 '24 14:05 c121914yu

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

我们就是开了10个大模型进程呀,然后同时进行10个请求,通过FastGPT中转之后老是报Premature close,如果直接连大模型的/v1/chat/completion接口就正常,大佬有什么好的建议嘛,感谢!

lktsuer avatar May 31 '24 00:05 lktsuer

大模型的问题吧 和fastgpt没关系。并发起来可能显存炸了

大模型并发用的unicorn,开了10个worker,直连压测是OK的 请问咱多用户同时请求大模型的时候,会中断其他的sse连接,仅保留单个连接吗

肯定是每个请求一个哇,saas 版都能几百并发😂

我们就是开了10个大模型进程呀,然后同时进行10个请求,通过FastGPT中转之后老是报Premature close,如果直接连大模型的/v1/chat/completion接口就正常,大佬有什么好的建议嘛,感谢!

不懂。。我们部署的模型还没遇到过这个问题,只有爆显存。

c121914yu avatar May 31 '24 04:05 c121914yu