Ubuntu + Nodejs + curl: (52) Empty reply from server
Ubuntu + Nodejs + curl: (52) Empty reply from server
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.
res
console.log(statistic)
res.json(statistic)
statistic
What's even more interesting - this setup worked perfectly fine for some time...
UPD: ufw is disabled.
Do you can run curl with
-v
parameter (for verbose). And what happens when you try on the root route?– Lucas Costa
Aug 22 at 14:19
-v
@user158 no, it's very undesirable
– zzomrot
Aug 22 at 14:20
@zzomrot why is that? aren't you in a testing environment? I said so because you have said that things worked fine previously.
– user158
Aug 22 at 14:29
What version of node are you running? What happens when you try using
res.json()
outside of the promise scope? If node is using the same or later version of V8 that Chrome 32 uses then promises are likely natively supported.– dcd018
Aug 22 at 14:37
res.json()
1 Answer
1
Sorry, i find error - in the nodejs code there is a part which parses a file. The file has expanded and the execution of the method takes a long time.
Apparently, it so coincided that when I made a request from a third-party server, the method managed to work out and return data, and when asked from the server itself did not have time.
I found an error when the server stopped returning the result to a third-party server and console.log(statistic)
before res.json(statistic)
stopped working.
console.log(statistic)
res.json(statistic)
Thank you for your replies!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
have you tried restarting the server?
– user158
Aug 22 at 14:15