python3 - 对 OSM API 的请求至少需要配置的连接超时持续时间

python3 - requests to OSM API take at least the configured connect timeout duration

我正在向 App Engine 请求 OSM 反向地理编码 API (https://nominatim.org/release-docs/develop/api/Reverse/)。配置无超时时,无限请求运行。配置连接和读取超时时,请求 returns 成功 总往返时间为 $connect_timeout 加上一个少量毫秒。这与:

相同

不会 发生在以下情况:

造成这种行为的原因是什么?

解决方法是不通过域名请求,而是使用 IP 地址请求(关闭 ssl 证书验证)。

这个请求很慢:

requests.get(url="https://nominatim.openstreetmap.org/reverse?lat=0&lon=0", headers={"Referrer": "https://www.example.org"}, timeout=4)

而这个请求很快:

requests.get(url="https://130.117.76.9/reverse?lat=0&lon=0", headers={"Referrer": "https://www.example.org"}, timeout=4, verify=False)

Google 似乎在内部对 openstreetmap 请求做了一些事情。

我已经为它开了一个issue:https://issuetracker.google.com/issues/171904232