使用"database.host": "localhost" 时连接很慢
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Read questdb_database.py, especially the conninfo construction and the default self.host value. Reproduce the localhost and 127.0.0.1 connection cases on Windows, then verify that instantiating QuestdbDatabase with database.host=localhost no longer incurs the reported delay.
Written by the indexing model from the issue text.
Description
┌─────────────────────────┬───────────────────────────┐
│ 测试 │ 耗时 │
├─────────────────────────┼───────────────────────────┤
│ ::1:8812 (IPv6) │ 立即拒绝 (WinError 10061) │
├─────────────────────────┼───────────────────────────┤
│ 127.0.0.1:8812 (IPv4) │ 0.000s ✅ │
├─────────────────────────┼───────────────────────────┤
│ host=127.0.0.1 直连 │ 0.000s ✅ │
├─────────────────────────┼───────────────────────────┤
│ host=localhost (第二次) │ 130.079s ❌ │
└─────────────────────────┴───────────────────────────┘
完整根因报告
问题
vnpy 调用 vnpy_questdb 启动慢(每次实例化 QuestdbDatabase 都额外卡 130 秒)。
根因
questdb_database.py 中 conninfo 拼接用的是 host=localhost:
self.conninfo: str = (
f"host={self.host} " # ← self.host 默认 "localhost"
f"port={self.port} "
...
)
在 Windows 上 localhost 解析为 ::1 (IPv6) 和 127.0.0.1 (IPv4)。QuestDB 默认只监听 IPv4(netstat 显示
0.0.0.0:8812),不接受 IPv6。
libpq 解析 localhost 后串行尝试每个地址,每个地址用尽默认 connect_timeout(~120 秒)后才尝试下一个。所以:
- 试 ::1 → 立即被 OS 拒绝 → libpq 不认为这是"快速失败",继续重试直到 ~120s 超时
- 才轮 127.0.0.1 → 成功 → 总耗时 ~130s
验证结果
- Dominant language
- Python
- Stars
- 3
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vnpy/vnpy_questdb
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
vnpy/vnpy_questdb#2 ·
All issues in vnpy/vnpy_questdb
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100