Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Ubuntu+;Nodejs+;curl:(52)来自服务器的空回复_Node.js_Ubuntu_Curl_Httpresponse - Fatal编程技术网

Node.js Ubuntu+;Nodejs+;curl:(52)来自服务器的空回复

Node.js Ubuntu+;Nodejs+;curl:(52)来自服务器的空回复,node.js,ubuntu,curl,httpresponse,Node.js,Ubuntu,Curl,Httpresponse,我有一个nodejs进程正在侦听服务器上的端口: app.get('/statistic', function(req, res) { log_get_connection(req); getStatistic().then(statistic => { res.json(statistic); }); }); 当我在同一台机器上尝试通过curl访问它时: curl "http://127.0.0.1:&

我有一个nodejs进程正在侦听服务器上的端口:

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

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

});
当我在同一台机器上尝试通过curl访问它时:

curl "http://127.0.0.1:<PORT>/statistic"
# or
curl "http://<EXT_IP>:<PORT>/statistic"
但是当我从另一台服务器通过curl访问它时,我看到一个成功的HTTP响应

我不重写
res
。另外,如果我将
console.log(statistic)
放在
res.json(statistic)
之前,我发现
statistic
是正确的

更有趣的是,这个设置在一段时间内运行得非常好


UPD:ufw被禁用。

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

显然,这是如此巧合,当我从第三方服务器发出请求时,该方法设法计算并返回数据,当服务器本身发出请求时,该方法没有时间

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


谢谢你的回复

是否尝试重新启动服务器?是否可以使用
-v
参数运行curl(用于详细说明)。当你尝试根路由时会发生什么?@user158不,这很简单undesirable@zzomrot为什么呢?您不是在测试环境中吗?我这么说是因为您之前说过一切正常。您正在运行哪个版本的node?在promise范围之外尝试使用
res.json()
时会发生什么?如果node使用的是chrome32使用的V8的相同或更高版本,那么承诺可能是本机支持的。
* Empty reply from server
* Connection #0 to host EXT_IP left intact

curl: (52) Empty reply from server