Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] trpc/edge/upload.createS3PreSignedUrl?batch=1 显示502 #5208

Closed
ywq2421 opened this issue Dec 27, 2024 · 23 comments
Closed

[Bug] trpc/edge/upload.createS3PreSignedUrl?batch=1 显示502 #5208

ywq2421 opened this issue Dec 27, 2024 · 23 comments
Labels
🐛 Bug Something isn't working | 缺陷 files 上传文件/知识库

Comments

@ywq2421
Copy link

ywq2421 commented Dec 27, 2024

📦 Environment

Docker

📌 Version

1.40.3

💻 Operating System

Ubuntu, Other Linux

🌐 Browser

Chrome

🐛 Bug Description

请求502,导致文件上传中断,另外,上传失败后,无法选择其他文件继续上传,选择文件上传按钮点不动

有时候刷新页面就能请求成功,有时候就502,确认服务正常,这里面在请求什么地址?
image

📷 Recurrence Steps

No response

🚦 Expected Behavior

文件正常上传

📝 Additional Information

No response

@ywq2421 ywq2421 added the 🐛 Bug Something isn't working | 缺陷 label Dec 27, 2024
@github-project-automation github-project-automation bot moved this to Roadmap - Chat 1.x in Lobe Chat Routine Dec 27, 2024
@lobehubbot
Copy link
Member

👀 @ywq2421

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

@dosubot dosubot bot added the files 上传文件/知识库 label Dec 27, 2024
Copy link

dosubot bot commented Dec 27, 2024

@ywq2421 你好!我是Dosu,一个能够帮助你解决bug、回答问题并成为贡献者的机器人。我在这里帮助你,等待人类维护者的到来。

The 502 Bad Gateway error you're encountering when accessing the trpc/edge/upload.createS3PreSignedUrl?batch=1 endpoint could be related to several factors, especially given the Docker environment and Nginx server setup. Here are some potential causes and solutions:

  1. Nginx Configuration: A 502 error often indicates that the Nginx server is unable to communicate with the upstream server (e.g., your application server). Check the Nginx configuration to ensure that the upstream server is correctly defined and that the server is running and accessible. Look for any misconfigurations in the proxy_pass directive or any timeout settings that might be too low.

  2. Application Server: Ensure that the application server handling the createS3PreSignedUrl endpoint is running without issues. Check the server logs for any errors or exceptions that might indicate why the server is not responding as expected.

  3. Docker Networking: If you're running the application in Docker, verify that the Docker network settings allow communication between the Nginx container and the application container. Ensure that the correct ports are exposed and mapped.

  4. tRPC Context and Headers: The unauthorized access and headers timeout errors in the tRPC context might be contributing to the issue. Ensure that the tRPC context is correctly configured to handle authentication and that any required headers are being sent with the requests. This might involve checking the middleware or authentication logic in your application.

  5. Intermittent Success: The fact that refreshing the page sometimes resolves the issue suggests a possible race condition or resource limitation. Investigate if there are any resource constraints (e.g., memory, CPU) on the server that could be causing intermittent failures.

  6. Error Handling: Implement robust error handling in your application to gracefully handle failed requests and allow users to retry uploads without needing to refresh the page.

By addressing these areas, you should be able to identify and resolve the cause of the 502 errors and improve the reliability of the file upload process.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@arvinxx
Copy link
Contributor

arvinxx commented Dec 27, 2024

502 是你的服务端没响应,应该是你的服务器挂了

@arvinxx arvinxx closed this as completed Dec 27, 2024
@github-project-automation github-project-automation bot moved this from Roadmap - Chat 1.x to Done in Lobe Chat Routine Dec 27, 2024
@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


502 means your server is not responding. It should be that your server is down.

@lobehubbot
Copy link
Member

@ywq2421

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

@ywq2421
Copy link
Author

ywq2421 commented Dec 27, 2024

你的意思是,我在一个时间节点,多次上传文件,然后服务挂了?然后我刷新页面后服务又好了是吗???docker服务是没有停止过的好不?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


You mean, I uploaded files multiple times at one point in time, and then the service hung up? Then I refresh the page and the service works again, right? ? ? The docker service has never been stopped, right?

@arvinxx
Copy link
Contributor

arvinxx commented Dec 28, 2024

你的意思是,我在一个时间节点,多次上传文件,然后服务挂了?然后我刷新页面后服务又好了是吗???docker服务是没有停止过的好不?

对。如果你的服务器性能较差的话,那么一次性同时上传多个文件的时候就会出现服务器没法 hold 住所有请求的情况,然后部分请求就会出现 502。这个跟docker是否有停止服务应该没太大关系。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


What do you mean, I uploaded files multiple times at one point in time, and then the service hung up? Then I refresh the page and the service works again, right? ? ? The docker service has never been stopped, right?

right. If your server's performance capabilities are poor, then when you upload multiple files at the same time, the server will not be able to hold all requests, and then some requests will appear 502. This should not have much to do with whether the docker request stops the service.

@ywq2421
Copy link
Author

ywq2421 commented Dec 28, 2024

单独将整个文件夹上传到minio是没问题的,和lobe部署在一个机器,而且也没看到cpu或内存占用飙升,性能我个人认为是够的,
如果开发团队有时间的话,建议排查优化一下项目整体。目前除了上传这个问题,还有就是lobe运行整体感觉都卡,这个并不是服务器的问题,而是流畅度的问题

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s no problem to upload the entire folder to minio alone, and deploy it on the same machine as lobe, and I haven’t seen a spike in CPU or memory usage. I personally think the performance is sufficient.
If the development team has time, it is recommended to investigate and optimize the overall project. At present, in addition to the problem of uploading, there is also the overall feeling that the lobe operation is stuck. This is not a problem of the server, but a problem of smoothness.

@arvinxx
Copy link
Contributor

arvinxx commented Dec 28, 2024

单独将整个文件夹上传到minio是没问题的,和lobe部署在一个机器,而且也没看到cpu或内存占用飙升,性能我个人认为是够的

如果你觉得不是你的设备性能问题的话,麻烦录个屏看下你的操作,需要包含浏览器控制台的 network 的部分,这样可以确认整个请求的情况。

image

以及如果遇到 502 出错的请求,麻烦给下这个请求的日志详情。

如果开发团队有时间的话,建议排查优化一下项目整体。目前除了上传这个问题,还有就是lobe运行整体感觉都卡,这个并不是服务器的问题,而是流畅度的问题

前端卡顿的性能优化是我们明年的一个关键事项,不过现在非常依赖底层模块 antd 的改版升级,估计可能要到明年年中才能根本解决。

如果可以的话也欢迎详细说明下你觉得现在卡顿的地方?模型设置页面已经在改版优化中了,不知道你觉得其他哪些地方还卡?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s no problem to upload the entire folder to minio alone, and deploy it on the same machine as lobe, and I haven’t seen a spike in CPU or memory usage. I personally think the performance is sufficient.

If you think it is not a problem with your device performance, please record a screen to see your operation. You need to include the network part of the browser console, so that you can confirm the entire request.

image

And if you encounter a request with a 502 error, please provide the log details of this request.

If the development team has time, it is recommended to investigate and optimize the overall project. At present, in addition to the problem of uploading, there is also the overall feeling that the lobe operation is stuck. This is not a problem of the server, but a problem of smoothness.

Optimizing the performance of front-end lag is a key issue for us next year, but now we are very dependent on the revision and upgrade of the underlying module antd. It is estimated that it may not be completely solved until the middle of next year.

If possible, please explain in detail what you think is stuck now? The model settings page is already being revised and optimized. I wonder what other areas do you think are still stuck?

@ywq2421
Copy link
Author

ywq2421 commented Dec 29, 2024

那我先期待一下明年的改版体验,上传文件视频如下
https://github.com/user-attachments/assets/26fa1565-c434-4042-b054-04a17139ad64

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Then I am looking forward to next year’s revision experience. The uploaded file video is as follows
https://github.com/user-attachments/assets/26fa1565-c434-4042-b054-04a17139ad64

@arvinxx
Copy link
Contributor

arvinxx commented Dec 29, 2024

@ywq2421 根据你的视频中的情况来看,是部分成功,然后部分出现502,我觉得大概率应该是被限制并发了。你用的网关是nginx 吗?能否检查下有没有限制了最大的同时请求数之类的配置。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@ywq2421 According to the situation in your video, it is partially successful, and then 502 appears partially. I think there is a high probability that concurrency is restricted. Is the gateway you use nginx? Can you check if there is any configuration that limits the maximum number of simultaneous requests?

@ywq2421
Copy link
Author

ywq2421 commented Dec 29, 2024

是nginx,你是指这个吗,其他的配置都是默认,未作改动
events { worker_connections 65535; }
暂时先这样把,不清楚什么问题,我先减少并发上传,另外i在看日志过程中,好像存在文件主键冲突,这个是否会影响文件上传,你们入库的主键hashid是依据什么计算的
image

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It's nginx, do you mean this? Other configurations are default and have not been changed.
events { worker_connections 65535; }
Let’s leave it like this for the time being. I’m not sure what the problem is. I’ll reduce concurrent uploads first. In addition, when looking at the logs, it seems that there is a file primary key conflict. Will this affect file uploads? What is the basis for calculating the primary key hasid in your database?
image

@arvinxx
Copy link
Contributor

arvinxx commented Dec 30, 2024

是nginx,你是指这个吗,其他的配置都是默认,未作改动

`events {

worker_connections 65535;

}`

暂时先这样把,不清楚什么问题,我先减少并发上传,另外i在看日志过程中,好像存在文件主键冲突,这个是否会影响文件上传,你们入库的主键hashid是依据什么计算的

image

哎 这个有点奇怪哎。主键hash是按照文件内容来算的。如果文件 hash 一样的情况下理论上就会触发这个抛错。

但在前端我是做了路由的,会先确认下文件在不在,如果存在一样的hash就会自动跳过上传,拿库里已有的记录来存。

这个能稳定复现吗?如果能稳定复现应该是个bug,我修一下

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It's nginx, do you mean this? Other configurations are default and have not been changed.

`events {

worker_connections 65535;

}`

Let’s leave it like this for the time being. I’m not sure what the problem is. I’ll reduce concurrent uploads first. In addition, when looking at the logs, it seems that there is a file primary key conflict. Will this affect file uploads? What is the basis for calculating the primary key hasid in your database?

image

Hey, this is a bit strange. The primary key hash is calculated based on the file. If the file hash is the same, this error will theoretically be triggered. But I have done routing on the front end. I will first confirm whether the file exists. If the same hash exists, it will automatically skip uploading and save the existing records in the library. Can this be reproduced stably? If it can be reproduced stably, it should be a bug. I'll fix it.

@ywq2421
Copy link
Author

ywq2421 commented Dec 30, 2024

似乎是版本问题导致,刚更新了最新版本,这个问题无法复现了,目前来看没什么问题了,祝lobe越来越好

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It seems to be caused by a version problem. I just updated to the latest version and this problem cannot be reproduced. It seems that there is no problem so far. I wish Lobe better and better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷 files 上传文件/知识库
Projects
Status: Done
Development

No branches or pull requests

3 participants