docs: Enhance timestamp/timezone troubleshooting based on Issue #60

Enhanced the Exchange API errors section with more detailed solutions
for timestamp-related failures, based on Issue #60.
Problem:
- code=-1021: Timestamp outside of recvWindow
- System time not synced with Binance servers
- Docker container time drift
Enhanced Solutions:
1. System Time Sync (Multiple methods)
   - ntpdate pool.ntp.org (recommended)
   - ntpdate with different NTP servers
   - timedatectl for automatic sync
   - Aliyun NTP for China users
2. Docker-specific fixes
   - Check container time vs host time
   - Restart Docker service
   - Add TZ environment variable
3. API Key verification steps
   - Regeneration procedure
   - Permission checklist
4. Rate limit considerations
   - Reduce trader count
   - Increase decision interval
Both English and Chinese versions updated.
Fixes: #60
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
Liu Xiang Qian
2025-11-02 11:44:57 +08:00
parent 24855b4859
commit dee040e35b
2 changed files with 120 additions and 24 deletions

View File

@@ -275,24 +275,72 @@ NOFX_BACKEND_PORT=8081
#### ❌ Exchange API Errors #### ❌ Exchange API Errors
**Error:** `invalid signature` / `timestamp` errors **Common Errors:**
- `code=-1021, msg=Timestamp for this request is outside of the recvWindow`
- `invalid signature`
- `timestamp` errors
**Solutions:** **Root Cause:**
1. **Check System Time:** System time is inaccurate, differing from Binance server time by more than allowed range (typically 5 seconds).
```bash
date # Should be accurate
# If wrong, sync with NTP:
sudo ntpdate -s time.nist.gov
```
2. **Verify API Keys:** **Solution 1: Sync System Time (Recommended)**
```bash
# Method 1: Use ntpdate (most common)
sudo ntpdate pool.ntp.org
# Method 2: Use other NTP servers
sudo ntpdate -s time.nist.gov
sudo ntpdate -s ntp.aliyun.com # Aliyun NTP (fast in China)
# Method 3: Enable automatic time sync (Linux)
sudo timedatectl set-ntp true
# Verify time is correct
date
# Should show current accurate time
```
**Docker Environment Special Note:**
If using Docker, container time may be out of sync with host:
```bash
# Check container time
docker exec nofx-backend date
# If time is wrong, restart Docker service
sudo systemctl restart docker
# Or add timezone in docker-compose.yml
environment:
- TZ=Asia/Shanghai # or your timezone
```
**Solution 2: Verify API Keys**
If errors persist after time sync:
1. **Check API Keys:**
- Not expired - Not expired
- Have correct permissions (Futures enabled) - Have correct permissions (Futures enabled)
- IP whitelist includes your server IP - IP whitelist includes your server IP
3. **Rate Limits:** 2. **Regenerate API Keys:**
- Binance has strict rate limits - Login to Binance → API Management
- Reduce number of traders or decision frequency - Delete old key
- Create new key
- Update NOFX configuration
**Solution 3: Check Rate Limits**
Binance has strict API rate limits:
- **Requests per minute limit**
- Reduce number of traders
- Increase decision interval (e.g., from 1min to 3-5min)
**Related Issue:** [#60](https://github.com/tinkle-community/nofx/issues/60)
--- ---

View File

@@ -275,24 +275,72 @@ NOFX_BACKEND_PORT=8081
#### ❌ 交易所 API 错误 #### ❌ 交易所 API 错误
**错误:** `invalid signature` / `timestamp` 错误 **常见错误:**
- `code=-1021, msg=Timestamp for this request is outside of the recvWindow`
- `invalid signature`
- `timestamp` 错误
**解决方案:** **根本原因:**
1. **检查系统时间:** 系统时间不准确,与币安服务器时间相差超过允许范围(通常是 5 秒)。
```bash
date # 应该准确
# 如果错误,与 NTP 同步:
sudo ntpdate -s time.nist.gov
```
2. **验证 API 密钥:** **解决方案 1: 同步系统时间(推荐)**
```bash
# 方法 1: 使用 ntpdate (最常用)
sudo ntpdate pool.ntp.org
# 方法 2: 使用其他 NTP 服务器
sudo ntpdate -s time.nist.gov
sudo ntpdate -s ntp.aliyun.com # 阿里云 NTP (中国大陆快)
# 方法 3: 启用自动时间同步 (Linux)
sudo timedatectl set-ntp true
# 验证时间是否正确
date
# 应该显示正确的当前时间
```
**Docker 环境特别注意:**
如果使用 Docker容器时间可能与宿主机不同步
```bash
# 检查容器时间
docker exec nofx-backend date
# 如果时间错误,重启 Docker 服务
sudo systemctl restart docker
# 或在 docker-compose.yml 中添加时区设置
environment:
- TZ=Asia/Shanghai # 或您的时区
```
**解决方案 2: 验证 API 密钥**
如果时间同步后仍有错误:
1. **检查 API 密钥:**
- 未过期 - 未过期
- 有正确权限(已启用合约) - 有正确权限(已启用合约)
- IP 白名单包含您的服务器 IP - IP 白名单包含您的服务器 IP
3. **速率限制:** 2. **重新生成 API 密钥:**
- 币安有严格的速率限制 - 登录币安 → API 管理
- 减少交易员数量或决策频率 - 删除旧密钥
- 创建新密钥
- 更新 NOFX 配置
**解决方案 3: 检查速率限制**
币安有严格的 API 速率限制:
- **每分钟请求数限制**
- 减少交易员数量
- 增加决策间隔时间(例如从 1 分钟改为 3-5 分钟)
**相关 Issue:** [#60](https://github.com/tinkle-community/nofx/issues/60)
--- ---