Ubuntu + Nodejs + curl: (52) Empty reply from server

时间:2018-08-22 13:51:39

标签: node.js ubuntu curl httpresponse

I have a nodejs process listening a port on my server:

app.get('/statistic', function(req, res) {
        log_get_connection(req);

        getStatistic().then(statistic => {
                res.json(statistic);
        });

});

When I try to access it via curl being on the same machine:

curl "http://127.0.0.1:<PORT>/statistic"
# or
curl "http://<EXT_IP>:<PORT>/statistic"

I get:

* Empty reply from server
* Connection #0 to host EXT_IP left intact

curl: (52) Empty reply from server

But when I access it via curl from another server I see a successful HTTP response.

I don't override res. Also if I put console.log(statistic) before res.json(statistic), I see that statistic is correct.

What's even more interesting - this setup worked perfectly fine for some time...

UPD: ufw is disabled.

1 个答案:

答案 0 :(得分:0)

对不起,我发现错误-在nodejs代码中有一部分可以解析文件。文件已扩展,该方法的执行需要很长时间。

很明显,这恰好使我从第三方服务器发出请求时,该方法设法计算出并返回数据,而当服务器本身询问该方法没有时间时。

当服务器停止将结果返回给第三方服务器并且在console.log(statistic)停止工作之前res.json(statistic)时,我发现了一个错误。

感谢您的答复!