docs: 添加后端检查和网络问题诊断报告
This commit is contained in:
141
BACKEND_CHECK_REPORT.md
Normal file
141
BACKEND_CHECK_REPORT.md
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
# 后端服务检查报告
|
||||||
|
|
||||||
|
**检查时间**: 2026-03-23 23:40
|
||||||
|
**检查结果**: ✅ 后端服务正常
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 **检查结果**
|
||||||
|
|
||||||
|
### 1. **后端服务状态** ✅
|
||||||
|
- **进程**: Java 进程正在运行 (PID: 56791)
|
||||||
|
- **端口**: 5010 端口正常监听
|
||||||
|
- **JAR 包**: monisuo-1.0.jar (41MB, 编译成功)
|
||||||
|
|
||||||
|
### 2. **API 接口测试** ✅
|
||||||
|
|
||||||
|
**测试接口**: `GET /api/wallet/default`
|
||||||
|
|
||||||
|
**返回结果**:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": "0000",
|
||||||
|
"msg": "操作成功",
|
||||||
|
"data": {
|
||||||
|
"address": "TRX1234567890abcdefghijklmnopqrstuvwxyz1234",
|
||||||
|
"name": "USDT-TRC20 主钱包",
|
||||||
|
"id": 1,
|
||||||
|
"network": "TRC20"
|
||||||
|
},
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**结论**: ✅ 后端 API 正常响应
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔍 **问题分析**
|
||||||
|
|
||||||
|
**现象**: 前端报"网络连接失败"
|
||||||
|
|
||||||
|
**原因**: 前端和后端的网络连接问题
|
||||||
|
|
||||||
|
**可能原因**:
|
||||||
|
1. ⚠️ 前端配置的 API 地址不正确
|
||||||
|
2. ⚠️ 前端请求跨域问题
|
||||||
|
3. ⚠️ 前端网络配置错误
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ **检查前端配置**
|
||||||
|
|
||||||
|
### 检查前端 API 配置
|
||||||
|
|
||||||
|
在 Flutter 项目中检查 API 配置:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/Desktop/projects/monisuo/flutter_monisuo
|
||||||
|
grep -r "baseUrl\|BASE_URL\|api.*url" lib/
|
||||||
|
```
|
||||||
|
|
||||||
|
**预期配置**:
|
||||||
|
- 本地开发: `http://localhost:5010`
|
||||||
|
- 生产环境: `http://8.155.172.147:5010`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📝 **解决方案**
|
||||||
|
|
||||||
|
### 方案 1: 检查前端 API 地址
|
||||||
|
|
||||||
|
**文件**: `flutter_monisuo/lib/core/constants/api_endpoints.dart`
|
||||||
|
|
||||||
|
**正确配置**:
|
||||||
|
```dart
|
||||||
|
class ApiEndpoints {
|
||||||
|
// 本地开发环境
|
||||||
|
static const String baseUrl = 'http://localhost:5010';
|
||||||
|
|
||||||
|
// 或生产环境
|
||||||
|
// static const String baseUrl = 'http://8.155.172.147:5010';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 方案 2: 检查跨域配置
|
||||||
|
|
||||||
|
**后端已配置 CORS**:
|
||||||
|
```java
|
||||||
|
// WebConfig.java
|
||||||
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||||
|
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||||
|
```
|
||||||
|
|
||||||
|
### 方案 3: 检查前端网络请求
|
||||||
|
|
||||||
|
**使用 Dio 或 HTTP 包**:
|
||||||
|
```dart
|
||||||
|
final dio = Dio(BaseOptions(
|
||||||
|
baseUrl: 'http://localhost:5010',
|
||||||
|
connectTimeout: 5000,
|
||||||
|
receiveTimeout: 3000,
|
||||||
|
));
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧪 **测试建议**
|
||||||
|
|
||||||
|
### 1. **测试后端接口**(已通过 ✅)
|
||||||
|
```bash
|
||||||
|
curl http://localhost:5010/api/wallet/default
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. **测试前端网络请求**
|
||||||
|
在 Flutter 中添加日志:
|
||||||
|
```dart
|
||||||
|
print('请求 URL: $baseUrl/api/fund/deposit');
|
||||||
|
print('请求参数: $data');
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. **检查浏览器控制台**
|
||||||
|
- F12 打开开发者工具
|
||||||
|
- Console 选项卡查看错误
|
||||||
|
- Network 选项卡查看请求
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ **结论**
|
||||||
|
|
||||||
|
**后端服务**: ✅ 正常运行
|
||||||
|
**StackOverflowError**: ✅ 已修复
|
||||||
|
**网络连接失败**: ⚠️ 前端配置问题
|
||||||
|
|
||||||
|
**下一步**: 检查前端 API 配置和网络请求
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**检查完成时间**: 2026-03-23 23:40
|
||||||
|
**后端状态**: ✅ 正常
|
||||||
|
**API 状态**: ✅ 正常
|
||||||
169
NETWORK_ERROR_DIAGNOSIS.md
Normal file
169
NETWORK_ERROR_DIAGNOSIS.md
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
# 网络连接失败问题诊断
|
||||||
|
|
||||||
|
**诊断时间**: 2026-03-23 23:41
|
||||||
|
**问题**: 前端报"网络连接失败"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔍 **问题根源**
|
||||||
|
|
||||||
|
### **前端配置**
|
||||||
|
|
||||||
|
**文件**: `flutter_monisuo/lib/core/constants/api_endpoints.dart`
|
||||||
|
|
||||||
|
```dart
|
||||||
|
static const String _env = String.fromEnvironment('ENV', defaultValue: 'dev');
|
||||||
|
|
||||||
|
static const String baseUrl = _env == 'prod'
|
||||||
|
? 'http://8.155.172.147:5010'
|
||||||
|
: 'http://localhost:5010';
|
||||||
|
```
|
||||||
|
|
||||||
|
**配置分析**:
|
||||||
|
- **开发环境** (默认): `http://localhost:5010`
|
||||||
|
- **生产环境** (ENV=prod): `http://8.155.172.147:5010`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 **当前状态**
|
||||||
|
|
||||||
|
### **本地后端服务** ✅
|
||||||
|
- **地址**: `http://localhost:5010`
|
||||||
|
- **状态**: ✅ 正常运行
|
||||||
|
- **测试**: ✅ API 接口正常响应
|
||||||
|
|
||||||
|
### **远程后端服务** ❓
|
||||||
|
- **地址**: `http://8.155.172.147:5010`
|
||||||
|
- **状态**: ❓ 未知(需要检查)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 **解决方案**
|
||||||
|
|
||||||
|
### **方案 1: 检查远程服务器后端**
|
||||||
|
|
||||||
|
在远程服务器上执行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh root@8.155.172.147
|
||||||
|
|
||||||
|
# 检查后端服务是否运行
|
||||||
|
ps aux | grep monisuo-1.0.jar
|
||||||
|
|
||||||
|
# 检查端口是否监听
|
||||||
|
netstat -tunlp | grep 5010
|
||||||
|
|
||||||
|
# 查看服务日志
|
||||||
|
tail -f /var/log/monisuo/app.log
|
||||||
|
|
||||||
|
# 如果服务未运行,启动服务
|
||||||
|
cd /path/to/monisuo
|
||||||
|
git pull origin main
|
||||||
|
systemctl restart monisuo
|
||||||
|
# 或
|
||||||
|
nohup java -jar target/monisuo-1.0.jar --server.port=5010 > /var/log/monisuo/app.log 2>&1 &
|
||||||
|
```
|
||||||
|
|
||||||
|
### **方案 2: 使用本地后端(开发环境)**
|
||||||
|
|
||||||
|
如果前端是在本地运行(开发环境):
|
||||||
|
|
||||||
|
1. **确保后端服务在本地运行**
|
||||||
|
```bash
|
||||||
|
cd ~/Desktop/projects/monisuo
|
||||||
|
java -jar target/monisuo-1.0.jar --server.port=5010
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **前端连接本地后端**
|
||||||
|
- 前端默认配置是 `http://localhost:5010`
|
||||||
|
- 无需修改配置
|
||||||
|
|
||||||
|
### **方案 3: 检查网络连接**
|
||||||
|
|
||||||
|
**在浏览器中测试**:
|
||||||
|
1. 打开浏览器
|
||||||
|
2. 访问 `http://localhost:5010/api/wallet/default`
|
||||||
|
3. 查看是否能正常访问
|
||||||
|
|
||||||
|
**如果无法访问**:
|
||||||
|
- 检查防火墙设置
|
||||||
|
- 检查浏览器安全策略
|
||||||
|
- 检查 CORS 配置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎯 **推荐操作**
|
||||||
|
|
||||||
|
### **立即检查远程服务器**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. SSH 登录服务器
|
||||||
|
ssh root@8.155.172.147
|
||||||
|
|
||||||
|
# 2. 检查服务状态
|
||||||
|
systemctl status monisuo
|
||||||
|
|
||||||
|
# 3. 如果服务未运行,启动服务
|
||||||
|
cd /path/to/monisuo
|
||||||
|
git pull origin main
|
||||||
|
systemctl restart monisuo
|
||||||
|
|
||||||
|
# 4. 查看启动日志
|
||||||
|
journalctl -u monisuo -f
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📝 **检查清单**
|
||||||
|
|
||||||
|
- [ ] 检查远程服务器后端是否运行
|
||||||
|
- [ ] 检查远程服务器端口 5010 是否开放
|
||||||
|
- [ ] 检查防火墙规则
|
||||||
|
- [ ] 检查前端环境变量配置
|
||||||
|
- [ ] 测试后端 API 接口
|
||||||
|
- [ ] 查看后端日志
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚨 **常见问题**
|
||||||
|
|
||||||
|
### **问题 1: 端口未开放**
|
||||||
|
|
||||||
|
**症状**: 无法连接到远程服务器
|
||||||
|
|
||||||
|
**解决**:
|
||||||
|
```bash
|
||||||
|
# 开放端口 5010
|
||||||
|
firewall-cmd --add-port=5010/tcp --permanent
|
||||||
|
firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
### **问题 2: 服务未启动**
|
||||||
|
|
||||||
|
**症状**: 端口未监听
|
||||||
|
|
||||||
|
**解决**:
|
||||||
|
```bash
|
||||||
|
systemctl restart monisuo
|
||||||
|
```
|
||||||
|
|
||||||
|
### **问题 3: CORS 问题**
|
||||||
|
|
||||||
|
**症状**: 浏览器控制台报 CORS 错误
|
||||||
|
|
||||||
|
**解决**: 后端已配置 CORS,应该不会有此问题
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ **总结**
|
||||||
|
|
||||||
|
**后端服务**: ✅ 本地正常
|
||||||
|
**前端配置**: ✅ 正确
|
||||||
|
**问题**: ⚠️ 远程服务器后端可能未运行
|
||||||
|
|
||||||
|
**下一步**: 检查远程服务器后端服务状态
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**诊断完成时间**: 2026-03-23 23:41
|
||||||
|
**建议**: 优先检查远程服务器后端是否运行
|
||||||
Reference in New Issue
Block a user