【问题标题】:Prevent 504 gateway timeout on overpass api with piped node request使用管道节点请求防止立交桥 API 上的 504 网关超时
【发布时间】:2016-08-13 21:23:09
【问题描述】:

我将以下代码用于 OpenStreetMap 查询(立交桥 API)。它适用于较小的查询,但对于较大的查询(大约需要 10 分钟),它只会生成 504 网关超时响应。

代码:

var reqStr = "http://overpass.osm.rambler.ru/cgi/interpreter?data=...

console.time("query");
var stream = request(reqStr,{timeout: 3600000}).on('error', function(err) {
    console.log(err)
}).pipe(fs.createWriteStream('resultExport.json'));
stream.on('finish', function () {
    console.timeEnd("query");
});

响应(resultExport.json):

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>504 Gateway Time-out</title>
</head><body>
<h1>Gateway Time-out</h1>
<p>The gateway did not receive a timely response
from the upstream server or application.</p>
</body></html>

查询命令有一个 [timeout:3600](秒),请求得到 {timeout:3600000}(毫秒)。我还能做些什么来防止超时并获得正确的响应?我有点困惑这是从哪里来的。

【问题讨论】:

    标签: json node.js request openstreetmap overpass-api


    【解决方案1】:

    这是一个已知问题,尚未在 Overpass API 服务器上解决/修复。

    详情请参阅此 Github 问题:https://github.com/drolbr/Overpass-API/issues/220

    【讨论】:

    • 所以没有办法进行查询,需要超过几分钟的时间?
    • 嗯,是的,这就是我在 Github 上创建这张票的原因。如果您的查询需要很长时间才能产生第一个结果,您将遇到超时。如果您的查询很早就开始产生一些数据并且只是连续返回数据,那么您应该没问题。也许您的 bbox 太大或您的查询太复杂?无法确定,因为您没有提供查询。
    猜你喜欢
    • 2017-11-21
    • 2013-04-06
    • 1970-01-01
    • 2011-04-26
    • 2016-08-16
    • 2014-07-02
    • 2019-09-03
    • 2013-12-03
    • 1970-01-01
    相关资源
    最近更新 更多